Friday, July 31, 2009

How to store an uploaded file to a variable in PHP?

Is there a way to store a file to a variable rather than copying or moving it to a specified location in the server?

How to store an uploaded file to a variable in PHP?
Yes, you can use the file_get_contents() function.





Example where the field name for the uploaded file is "source":





%26lt;?php


$filename = $_FILES['source']['tmp_name'];


$text = file_get_contents($filename);





echo "This is the contents: $text";


?%26gt;


No comments:

Post a Comment