简体   繁体   中英

CURL + $GLOBALS[“HTTP_RAW_POST_DATA”] in PHP

I'm using CURL to upload files to a service.

currently I'm getting the file content with $GLOBALS["HTTP_RAW_POST_DATA"] then save it on my server.

after that, I'm using CURLOPT_POSTFIELDS with the file's full path. Is there a way to send the file content directly, without saving it on my server, as if I saved it?

Or is there a way to upload a Photo from a flash app to facebook album, without saving it on the server?

Thanks

If you are uploading data you might consider using the file upload mechanism in PHP http://php.net/manual/en/features.file-upload.php It automatically handls file upload PHP.

If you want to redirect the upload to another (third party service) without needing to be in the chain of commands (ie user->3rd party server), you might want to look into AJAX. AFAIK when you upload a file using PHP/forms the file will be uploaded to your PHP temp directory and there is no way to prevent this because:
1. To access the file it needs to be on the server (PHP is server execute meaning it can not execute on the user side)
2. I do not believe any user will want you to access their files on their computer nor will you be able to do so(Firewall, AV), if that were to happen it will be a major security issue

As I said above, what you want to look into is AJAX (I used jquery and their AJAX methods are very simple). Because AJAX is user execute javascript it can run on the machine and initiate a connection to any URL. This way you can directly access the service without submitting the file to your server.

Here is an exmaple AJAX upload (you can google for more): http://valums.com/ajax-upload/

Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM