0

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
 ?>
2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by peter_budo
0

How is this relevant to JSP?

i think progress bar can be creat with JSP

0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.