...

View Full Version : Easy uploader needed



agruber
01-18-2010, 09:55 PM
Warning: I'm new at PHP.

That said, here's what I need. I need to share files with clients often. The current solution is upload the file to an FTP server and then forward the client a URL that will directly download the file.

Basics of what I need:
- simple web interface that would allow anyone to upload files
- show the progress of the file upload
- when upload is complete return a download link that can be copied and emailed
- secure

Extras that would be nice:
- limit files to ZIP or PDF
- dropdown menu that would allow the uploader to select the client they are uploading for (this would then place the file in the respective client's folder)

So can it be done and how hard is it to do?

Fumigator
01-18-2010, 10:14 PM
Yes it's possible, pretty easy actually, as long as you drop the progress bar requirement. You can use Ajax to display a progress bar but that's going to complicate matters. My advice for someone who has never programmed in PHP before would be to get it all working without the progress bar first, then maybe revisit the application later.

You want to look into file uploads:

http://us3.php.net/manual/en/features.file-upload.post-method.php

And sessions to limit access to the website:

http://us3.php.net/manual/en/function.session-start.php

_Aerospace_Eng_
01-18-2010, 10:45 PM
Or maybe something premade might give you a starting point.

http://www.solitude.dk/filethingie/

There is a lot more out there but if you search for php file manager.

sir.jones
01-19-2010, 11:38 AM
displaying the form.

<FORM ENCTYPE="multipart/form-data" ACTION="upload.php" METHOD=POST>
Upload this file: <INPUT NAME="file_up" TYPE="file">
<INPUT TYPE="submit" VALUE="Send File"></FORM>


Here is the php code.


<? //upload.php
$file_upload=true;
$file_up_size=$_FILES['file_up'][size];
echo $_FILES[file_up][name];
if ($_FILES[file_up][size]>250000){$msg=$msg."Your uploaded file size is more than 250KB not allowed. \n";
$file_upload=false;}

if (!($_FILES[file_up][type] =="file/zip" OR $_FILES[file_up][type] =="file/pdf")){$msg=$msg."Just ZIP or PDF. allowed \n";
$file_upload=false;}

$file_name=$_FILES[file_up][name];
$add="upload/$file_name "; // upload is the directory name.
if($file_upload==true){

if(move_uploaded_file ($_FILES[file_up][tmp_name], $add)){
// a thanks message here.
}else{echo "Failed to upload file Contact Site admin to fix the problem \n";}

}else{echo $msg;}
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum