...

View Full Version : Upload Progress



Zeater
11-18-2007, 10:46 PM
Hi,

The following code uploads files to the server. How do I output to the user the progress of the upload, so the user is aware of how long the process is going to take?


<?php
if (($_FILES["file"]["type"] == "audio/mp3")
|| ($_FILES["file"]["type"] == "audio/x-mpeg"))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
$file = ($_FILES["file"]["name"]);
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
echo $_FILES["file"]["type"];
}
?>

mlseim
11-18-2007, 11:21 PM
I would say you need to use AJAX.

See the progress-bar thing they have here:
http://miniajax.com/



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum