JM4
JM4

Reputation: 6788

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!

Upvotes: 0

Views: 2644

Answers (1)

Bruce Armstrong
Bruce Armstrong

Reputation: 1602

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

Upvotes: 3

Related Questions