What i want is when i click upload button upload the file with progress bar

<form action="image_upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="filei" id="filei" />
<input type="submit" name="button2" id="button2" value="Upload" />
</form>

this is my php file

<?php
 $name=$_FILES["filei"]["name"];
  $size=$_FILES["filei"]["size"];
 $type1=$_FILES["filei"]["type"];

$dirpath = "upload/";
  //upload image
  if ((($_FILES["filei"]["type"] == "image/gif")
|| ($_FILES["filei"]["type"] == "image/jpeg")
|| ($_FILES["filei"]["type"] == "image/pjpeg")|| ($_FILES["file"]["type"] == "image/JPEG")|| ($_FILES["filei"]["type"] == "image/jpg")|| ($_FILES["filei"]["type"] == "audio/mpeg")|| ($_FILES["filei"]["type"] == "audio/x-mpegurl"))
&& ($_FILES["filei"]["size"] < 20000000000000))
  {
  if ($_FILES["filei"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["filei"]["error"] . "<br />";
    }
  else
    {
    echo "Upload: " . $_FILES["filei"]["name"] . "<br />";
    echo "Type: " . $_FILES["filei"]["type"] . "<br />";
    echo "Size: " . ($_FILES["filei"]["size"] / 1024) . " Kb<br />";
    echo "Temp file: " . $_FILES["filei"]["tmp_name"] . "<br />";

    if (file_exists("$dirpath" . $_FILES["filei"]["name"]))
      {
      echo $_FILES["filei"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["filei"]["tmp_name"],
      "$dirpath" . $_FILES["filei"]["name"]);
      echo "Stored in: " . "$dirpath" . $_FILES["filei"]["name"];
	  $ipath = "$dirpath" . $_FILES["filei"]["name"];
      }
    }
  }
else
  {
  echo "Invalid file";
  }
  //end of image uploading
 ?>

Recommended Answers

All 3 Replies

How is this relevant to JSP?

How is this relevant to JSP?

i think progress bar can be creat with JSP

Use jQuery for such thing. Further recommendation do not mix-up PHP with Java. Java servlet provides you with file upload/download too

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.