• Ajax Image Upload With Progress Bar using PHP

    Here i have mentioned code for Ajax image upload with progress bar using PHP.

    Step 1 : Create one HTML file and paste this code.

    File name will be upload_file.html

    1
    
    &lt;!doctype html&gt;<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script><script type="text/javascript" src="http://malsup.github.com/jquery.form.js"></script>

    Ajax File Upload Demo

    0%

    Step 2 :

    Create php file and paste this code. This code is for upload image with php code.

    File name will be upload_file_u.php

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    
    <!--?php 
    //upload.php
    $output_dir = "uploads/";
     
    if(isset($_FILES["myfile"]))
    {
        //Filter the file types , if you want.
        if ($_FILES["myfile"]["error"] --> 0)
        {
          echo "Error: " . $_FILES["file"]["error"] . "
    ";
        }
        else
        {
            //move the uploaded file to uploads folder;
            move_uploaded_file($_FILES["myfile"]["tmp_name"],$output_dir. $_FILES["myfile"]["name"]);
     
         echo "Uploaded File :".$_FILES["myfile"]["name"];
        }
     
    }
    ?&gt;
    Tags:

Comments on this post

Leave a Reply

  • Security Code :


    four − = 2