Reputation: 5905
Much like this: http://www.w3schools.com/PHP/php_file_upload.asp
But I'd like to store the contents of the file into a variable. Is there a shortcut to this? (instead of saving it to a temp file, then opening the temp file and reading it into the variable)
Upvotes: 0
Views: 864
Reputation: 11595
That's how PHP uploads the file, into a temporary file, which you can read into a variable. You can use the function move_uploaded_file
if you want to move it somewhere without reading in the file contents and then writing them out, but there's not really any way to bypass the "upload to temp file" part of the process. You have to get it on the server somehow...
Upvotes: 1
Reputation: 13407
No, uploaded files are always stored in a tmp file using the pattern shown in http://www.w3schools.com/PHP/php_file_upload.asp.
However, you could allow a POST and do something like:
$in = fopen("php://stdin", "rb");
curl -v -X POST -d @filetoupload.xml --header Content-Type:application/xml http://host.com
Upvotes: 3