Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to upload a file in php ?

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 145
    Comment on it

    When you want to upload your curriculum vitae, Your Profile picture, on the server then you can use File uploading method in PHP.

    With php concept you can easily upload your resume and any other document.

    There are tow important property must be define for uploading any document

    1-post 2-"multipart/form-data"

    Firstly create a html script name is fileupload.html

    you can take reference of bellow example:

    <html>
    
       <body>
    
      <form action="fileupload.php" enctype="multipart/form-data" method="post">
    
    
         File Name <input type="file" name="file"/><br/>
    
        <input type="submit" value="Upload" name="upload"/>
    
      </form>
    
       </body>
    
      </html>
    

    Here enctype is a attribute of the tag

    Now create a php script name is fileupload.php

    multipart/form-data is used the contents of a file, to be uploaded.

    It will look like this:

    <?php
      if ($_POST['upload'] ){
    
         move_uploaded_file($_FILES["file"]["tmp_name"],
          "upload/" . $_FILES["file"]["name"]);  
            //here upload file
           echo "File_Upload: " . $_FILES["file"]["name"] . "<br>";
           //here call type to now file type
           echo "File_Type: " . $_FILES["file"]["type"] . "<br>";
    
         }  
    
    ?>
    

 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: