File upload problem

From: Date: Wed, 21 Apr 2004 15:59:06 +0000
Subject: File upload problem
Groups: php.general 
Request: Send a blank email to php-general+get-184151@lists.php.net to get a copy of this message
Hi, I have two php pages that upload files to a mysql db. I do not know how to change this code to accept more than plain text files. Specifically, I would like to accept .doc and .xls files. Can anyone help? Thanks...Will This is my upload form.... <body> <h3> Upload a New File</h3> <form enctype="multipart/form-data" action="item_upload.php" method=post> <input type="hidden" name="MAX_FILE_SIZE" value="100000"> Upload this file: <input name="userfile" type="file"> <input type="submit" value="Send File"> </form> </body> </html> This, I use to handle the uploaded file... <? if ($userfile=="none") { echo "Problem: no file uploaded"; exit; } if ($userfile_size==0) { echo "Problem: uploaded file is zero length"; exit; } if (!is_uploaded_file($userfile)) { echo "Problem: possibles file upload attack"; exit; } $upfile = "../uploads/".$userfile_name; if ( !copy($userfile, $upfile)) { echo "Problem: Could not move file into directory"; exit; } echo "File uploaded successfully<br><br>"; $fp = fopen($upfile, "r"); $contents = fread ($fp, filesize ($upfile)); fclose ($fp); $contents = strip_tags($contents); $fp = fopen($upfile, "w"); fwrite($fp, $contents); fclose($fp); echo "preview of uploaded file contents:<br><hr>"; echo $contents; echo "<br><hr>"; ?>

« previous php.general (#184151) next »