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
    • 256
    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.

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

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

    <?php
    
        if(!mkdir('./uploads/'))
        {
            mkdir('./uploads/',0777);
        }
    
        $upload = './uploads/';
    
        foreach($_FILES['photo']['name'] as $image_name => $imgName)
        {
            $imageName = $_FILES['photo']['name'][$image_name];
            $imageTempName = $_FILES['photo']['tmp_name'][$image_name];
            move_uploaded_file($imageTempName,$upload.$imageName);
            echo "File uploaded successfully!!!";           
        }                
    ?>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: