php FILE POST upload without save

前端 未结 6 2418
深忆病人
深忆病人 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-19 00:08

    The file has to be saved somewhere before reading in this case is the temporary directory; You can get the contents of the file from the temporary directory, then if you really need to you delete. See the following code:

    $file = file_get_contents($_FILES["ufiley"]["tmp_name"]);
    
    unlink($_FILES["ufiley"]["tmp_name"]); 
    
    //contents would be stored in $file
    

提交回复
热议问题