<form enctype="multipart/form-data" action="upload.php" method="POST">
<input name="uploaded" type="file" />
<input type="submit" value="Upload" />
</form>
<?php
if(isset($_REQUEST['submit'])){
$target = "data/".basename( $_FILES['uploaded']['name']) ;
move_uploaded_file($_FILES['uploaded']['tmp_name'], $target);
}
?>
I know Javascript, AJAX and JQuery etc very well and I believe an upload progress bar can be created using PHP, AJAX and Javascript etc.
I am surprised how to get the size of upload (meaning each second I want to know, how much of the file is uploaded and how much is remaining, I think it should be possible using AJAX etc) file during upload is in process.
Here is link to the PHP manual but I didn't understand that: http://php.net/manual/en/session.upload-progress.php
Is there any other method to show the upload progress bar using PHP and AJAX but without use of any external extension of PHP? I don't have access to php.ini
Introduction
The PHP Doc is very detailed it says
All the information you require is all ready in the PHP session naming
All you need is to extract this information and display it in your HTML form.
Basic Example
a.html
b.php
Example with PHP Session Upload Progress
Here is a better optimized version from PHP Session Upload Progress
JavaScript
progress.php
Other Examples
This is my code its working fine Try it :
Demo URL
http://codesolution.in/dev/jQuery/file_upload_with_progressbar/
Try this below code:-
this is my html code
My upload.php file code
XMLHTTPREQUSET2
While it may be good fun to write the code for a progress bar, why not choose an existing implementation. Andrew Valums wrote an excellent one and you can find it here:
http://fineuploader.com/
I use it in all my projects and it works like a charm.
First of all, make sure you have PHP 5.4 installed on your machine. You didn't tag php-5.4 so I don't know. Check by calling
echo phpversion();
(orphp -v
from the command line).Anyway, assuming you have the correct version, you must be able to set the correct values in the
php.ini
file. Since you say you can't do that, it's not worth me launching into an explanation on how to do it.As a fallback solution, use a Flash object uploader.
May I suggest you FileDrop.
I used it to make a progess bar, and it's pretty easy.
The only downside I met, is some problems working with large amounts of data, because it dosen't seem to clear up old files -- can be fixed manually.
Not written as JQuery, but it's pretty nice anyway, and the author answers questions pretty fast.