note 129685 added to class.curlfile

From: Date: Sun, 04 Aug 2024 14:28:23 +0000
Subject: note 129685 added to class.curlfile
Groups: php.notes 
Request: Send a blank email to php-notes+get-221458@lists.php.net to get a copy of this message
CURLFile() is great with Content-Type: "multipart/form-data". But, if you want to upload just a single file (e.g. for the Wordpress media API), then you have to do this WITHOUT using CURLFile(). i.e. 1. Set the relevant CURLOPT_HTTPHEADER values: "Content-Type: image/jpeg" "Content-Disposition: attachment; filename=myfile.jpg" (where the content-type needs to be the appropriate mime-type for the uploaded file, and filename is the basename of the file). 2. Post the file contents directly within CURLOPT_POSTFIELDS: file_get_contents($filename); ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.137 (proxied: 83.151.202.231) ---- Manual Page -- https://php.net/manual/en/class.curlfile.php Edit -- https://main.php.net/note/edit/129685 Del: integrated -- https://main.php.net/note/delete/129685/integrated Del: useless -- https://main.php.net/note/delete/129685/useless Del: bad code -- https://main.php.net/note/delete/129685/bad+code Del: spam -- https://main.php.net/note/delete/129685/spam Del: non-english -- https://main.php.net/note/delete/129685/non-english Del: in docs -- https://main.php.net/note/delete/129685/in+docs Del: other reasons-- https://main.php.net/note/delete/129685 Reject -- https://main.php.net/note/reject/129685 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221458) next »