Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Easy uploader needed

    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?

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    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/feature...ost-method.php

    And sessions to limit access to the website:

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

  • #3
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    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.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #4
    New Coder
    Join Date
    Dec 2009
    Posts
    84
    Thanks
    6
    Thanked 3 Times in 3 Posts
    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.

    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;}
    ?>
    Best Regards,


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •