php FILE POST upload without save

前端 未结 6 2419
深忆病人
深忆病人 2021-02-18 23:49

I am using a plain text file in a PhP script. Is there any way to process the file in the PhP script without saving it locally? Everywhere I see simply uploading a file and sav

6条回答
  •  滥情空心
    2021-02-18 23:55

    When the form is submitted, check the $_FILES['input_name']['tmp_name'] property. This is the path to your file saved in a temporary /tmp system path. You can proceed reading the name using, say, file_get_contents() and then simply forget the file. System will take care of removing it.


    Just to stand out of the other answers, you could theoretically read the file without even uploading it using JavaScript, see http://www.html5rocks.com/en/tutorials/file/dndfiles/. Then submit only the data you need as part of AJAX request.

提交回复
热议问题