note 45491 added to ref.curl

From: Date: Thu, 09 Sep 2004 03:08:23 +0000
Subject: note 45491 added to ref.curl
Groups: php.notes 
Request: Send a blank email to php-notes+get-76267@lists.php.net to get a copy of this message
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! ---- Manual Page -- http://www.php.net/manual/en/ref.curl.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+45491 Delete -- http://master.php.net/manage/user-notes.php?action=delete+45491&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+45491&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#76267) next »