I have a File Upload Form which looks like this:
[code=html]<form action=”./upload.php” method=”post” enctype=”multipart/form-data”>
<strong>File Location:</strong>
<input type=”file” name=”userfile” id=”file”>
<br />
<strong> Version:</strong>
<input name=”version” type=”text” size=”10″ />
<br />
<br />
<input type=”submit” value=”Upload File”>
</form>
What I am attempting to do is put together the PHP Code so that it processes the file, placing it into a temporary directory, pending approval from a Moderator. Once the user submits the file on the website, I need the page to re-direct to another page which shows the status on that pending file.
This is what I’ve put together so far:
[code=php]<?php
$allowed_filetypes = array(‘.txt’);
$max_filesize = 524288;
$upload_path = ‘./files/’;
$filename = $_FILES[‘userfile’][‘name’];
$ext = substr($filename, strpos($filename,’.’), strlen($filename)-1);
if(!in_array($ext,$allowed_filetypes))
die(‘Your attachment has been rejected due to an unaccepted filetype.’);
if(filesize($_FILES[‘userfile’][‘tmp_name’]) > $max_filesize)
die(‘The file you attempted to upload is too large.’);
if(!is_writable($upload_path))
die(‘You cannot upload to the specified directory, please CHMOD it to 777.’);
if(move_uploaded_file($_FILES[‘userfile’][‘tmp_name’],$upload_path . $filename))
echo ‘Success! Your Guide is pending approval from the Moderator. <a href=”‘ . $upload_path . $filename . ‘” title=”Your File”>here</a>’;
else
echo ‘Rejected. Please try again or contact the Administrator if the problem persists.’;
?>
Anyone know of any scripts or tutorials that does something like this?