简体   繁体   中英

How To: Upload text file and use with PHP script

Is it possible to achieve the following:

  1. Allow a user to upload a text file via HTML form (.txt)
  2. Use the contents of that file in a PHP script to temporarily access the information
  3. Delete any traces of the temporary file after the script has processed?

Think of it as uploading a word document via html form, have a php script as basic as:

<?php

$document = file_get_contents("uploaded_document.txt");

echo $document;

$document = "";

?>

Thank you ahead of time!

unlink($_FILES["txt_file"]["tmp_name"]);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM