Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • FIle Upload Code

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 272
    Comment on it

    Make sure that the shape employs method="post" The shape also desires the subsequent feature: enctype="multipart/form-data". This specifies which in turn content-type to utilize as soon as posting the form.

    Without worrying about demands above, the actual record post is not going to work.

    1. <form method="post" enctype="multipart/form-data">
    2. <div>Select file to upload</div>
    3. <div><input type="file" name="photo" id="photo" multiple="true"/></div>
    4. <input type="submit" name="sub" id="sub" value="submit" />
    5. </form>

    mkdir - make directory(folder) ./uploads/" - specifies the directory where the file is going to be placed

    1. <?php
    2.  
    3. if(!mkdir('./uploads/'))
    4. {
    5. mkdir('./uploads/',0777);
    6. }
    7.  
    8. $upload = './uploads/';
    9.  
    10. foreach($_FILES['photo']['name'] as $image_name => $imgName)
    11. {
    12. $imageName = $_FILES['photo']['name'][$image_name];
    13. $imageTempName = $_FILES['photo']['tmp_name'][$image_name];
    14. move_uploaded_file($imageTempName,$upload.$imageName);
    15. echo "File uploaded successfully!!!";
    16. }
    17. ?>

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: