/    Sign up×
Community /Pin to ProfileBookmark

Looking for Tutorial on File Upload Form/Queue

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>[/code]

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.’;

?>[/code]

Anyone know of any scripts or tutorials that does something like this?

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @Mesden spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...