Dysan Posted November 18, 2007 Share Posted November 18, 2007 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"]; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/77868-upload-progress/ Share on other sites More sharing options...
trq Posted November 18, 2007 Share Posted November 18, 2007 There is no simple solution to this question. You might want to google for ajax php upload progress or something similar. Quote Link to comment https://forums.phpfreaks.com/topic/77868-upload-progress/#findComment-394128 Share on other sites More sharing options...
MadTechie Posted November 19, 2007 Share Posted November 19, 2007 PHP can't get the data needed to do that (namely RAW_POST_DATA), so your need add some peal into the mix Quote Link to comment https://forums.phpfreaks.com/topic/77868-upload-progress/#findComment-394147 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.