Take file information?
So I know how to upload a file to a web-server with PHP. Instead of uploading it though, I just want to read the data from the开发者_开发知识库 file and use it, WITHOUT the upload part. Could someone link me up or give me an example plz?
from HTML, the file is always uploaded to the server, to a temp directory. if from PHP you don't move it to another directory, it will be deleted later, but you can still use it and read it on the script that handles the upload, as shown in the example of is_uploaded_file()
The only way to do that is to send the data of the file via POST and work with it via something like
$postData = file_get_contents( 'php://input' );
PHP is a server-side language, which means it either needs a server-side copy of the file (since it can't access the client) or you need to send parts of the file via common HTTP request methods that PHP can work with (POST or even GET)
There may be a way using JavaScript, but I can't think of any
a javascript possible solution:
https://developer.mozilla.org/en/DOM/FileReader
not cross-browser, works only in firefox and webkit html5 api compatible versions
精彩评论