note 45491 deleted from ref.curl by felipe

From: Date: Sun, 30 Mar 2008 19:09:04 +0000
Subject: note 45491 deleted from ref.curl by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-137772@lists.php.net to get a copy of this message
Note Submitter: gordon_e_rouse at yahoo dot com dot au ---- Multipart form uploads (ie simulating the upload of files from a browser form) is surprisingly easy, yet hard to find information on.... hope this changes that. $postData = array(); //simulates <input type="file" name="file_name"> $postData[ 'file_name' ] = "@test.txt"; $postData[ 'submit' ] = "UPLOAD"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url ); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_POST, 1 ); //seems no need to tell it enctype='multipart/data' it already knows curl_setopt($ch, CURLOPT_POSTFIELDS, $postData ); $response = curl_exec( $ch ); //where test.txt is a file in the same directory!

« previous php.notes (#137772) next »