Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Check file exists or not

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 260
    Comment on it

    Hello Reader's today we discuss about "Check file exists or not in Php".

    HTML code :

    <!DOCTYPE html>
    <html>
    <body>
    <?php echo $message; ?>
    <form enctype="multipart/form-data" method="POST">
    <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
    Choose a file to upload: <input name="uploadedfile[]" type="file" multiple="true" /><br />
    <input type="submit" value="Upload File" name="submit" id="submit" />
    </form>
    
    </body>
    </html>
    

    Php code:

    <?php
        $target_path = "new/"; // folder name
    
    
        if(isset($_POST['submit']))
        {
            $target_path = $target_path . basename( $_FILES['uploadedfile[]']['name']); 
    
                if( file_exists($target_path) )
                {       
                    $message =  "File Allready exists";    
                }
                else
                {       
                    move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path);
                    $message = "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: