#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    25
    Rep Power
    0

    How to allow users to upload files in a form?


    I want users to be able to upload zip/winrar files only with a browse file input on a form. I want the files to be added to a folder on my ftp server called ../user_upload/

    I have this coded in php:

    PHP Code:
    $string '0123456789';
    $string_shuffle str_shuffle($string);
    $half substr($string_shuffled03);
    $filename $half;


        
    $newname "$filename.jpg";
        
    move_uploaded_file$_FILES['fileField']['tmp_name'], "../user_upload/$newname"); 
    and then here is the html:

    Code:
    div class="row_upload">
    <div class="label">Upload Track(s)</div> <!-- end .label-->
    <div class="input">
    <input type="file" accept="application/zip,application/rar" name="fileField" id="fileField" value="test" />
    </div> <!-- end .input -->
    <div class="context">Upload your track(s) inside of a .ZIP or .RAR file ONLY</div><!-- end .context -->
    </div> <!-- end .row -->
    It won't work if anyone can help me it would be greatly appreciated!!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,618
    Rep Power
    595
    Search engines are your friend.

    http://www.tizag.com/phpT/fileupload.php
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    25
    Rep Power
    0
    Originally Posted by gw1500se
    Search engines are your friend.

    http://www.tizag.com/phpT/fileupload.php
    I actually used the code from that website prior to posting here. The code is not working for some reason. All the validation checks and renaming existing files are not of my concern. The file won't upload to the folder
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,618
    Rep Power
    595
    Perhaps you did not post enough of your code. For example where is your form and what 'action' does it call? Also do the following to see if $_FILES contains what you expect.
    PHP Code:
    echo "<pre>";
    print_r($_FILES);
    echo 
    "</pre>"
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    48
    Rep Power
    3
    It's also definitely possible that the permissions on your upload directory are too strict to allow an upload. What OS are you using?

IMN logo majestic logo threadwatch logo seochat tools logo