• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 558
  • Last Modified:

Having a progress bar in PHP while uploading a file to the server

I have 2 php files, where the first is the form at which you will have upload text area, and here is its code:
<form name="testform" method='POST' action='fileupload.php'>
<table border="0" cellspacing="0" bgcolor=WHITE align="center" >
<tr>
<td bgcolor=RED><font size="2" face="Arial" color=BLACK><b>Load File<br>PDF Only</b></font></td>
</td>
<td>
<input name="uploaded" type="file" size="50" maxlength="50" />
</td>
</tr>
<td colspan="2">
<center><input type="image" src="img/upload.gif" VALUE="Upload File" alt="Upload" /></td></center>
</td>
</tr>
</table>
</form>

And the second php (fileupload.php) is the action file, and here is its code:
<?php
$target = "filetmp/";
$uploaded_type=$_FILES['uploaded']['type'];
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;

//This is the only file type allowed
if (!($uploaded_type=="application/pdf"))
{
echo "You may only upload PDF files.<br>";
$ok=0;
}

//Here we check that $ok was not set to 0 by an error
if ($ok==0)
{
Echo "Sorry your file was not uploaded";
}

//If everything is ok we try to upload it
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploaded']['name']). " has been uploaded";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
?>

I want to insert a progress bar showing the file upload progress or at least a pop up window asking the user to wait until the file is uploaded, and then it disappears once the file is uploaded or rejected because of type mismatch, can someone tell me how can I do so with PHP?
0
Ashraf-Hassan
Asked:
Ashraf-Hassan
  • 5
  • 5
  • 2
1 Solution
 
NeoAshuraCommented:
this is the one i use for my site.. its very good and useful if u have any problems with it gimme a shout but it tells u EXACTLY what to do.

http://www.inaflashuploader.com/
0
 
Ashraf-HassanAuthor Commented:
The problem is that I can not use flash because iPhone does not support flash, is there any solution which is pure php?
0
 
leakim971PluritechnicianCommented:
Hello Ashraf-Hassan,

Php + Ajax one : http://www.seemysites.net/projFolder/uploader/

Regards.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
NeoAshuraCommented:
apologies didnt realise u where using the Iphone.. just a little tech thing.. Blackberry will soon be compatable with Flash.. :)
0
 
Ashraf-HassanAuthor Commented:
Well the Problem that Apple is not that friendly, it has been requested many many times to support flash by their users, but there is no clear justification.
leakim971, I downloaded the script, but unfortunately it is not working because of the json, my php is 5.1.x, do you have another package?
0
 
leakim971PluritechnicianCommented:
You've a class in the mail folder. Not the good one ?
0
 
Ashraf-HassanAuthor Commented:
Sorry I did not get your point, which mail folder?
0
 
leakim971PluritechnicianCommented:
not "mail", but "main" sorry
0
 
Ashraf-HassanAuthor Commented:
I think it needs json, I tried it, and it it is not working, I just get the upload spead 0.0 B/s, then nothing working in the bar nor the file is uploaded, what do you think?
0
 
leakim971PluritechnicianCommented:
What if your plateform ? Can you run CGI script (upload.cgi) ?
0
 
Ashraf-HassanAuthor Commented:
Thank you so much it is working.
0
 
leakim971PluritechnicianCommented:
You're welcome! Thanks for the points!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 5
  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now