I am uploading a file on my website. It works fine. Now i want to display progress bar while it take time in uploading. I have option to chenge uploading through ajax, but i can not use ajax. Can it possible to show without using ajax and without disturbing the code.
$image = new SimpleImage();
$objdjs= new Djs;
if(isset($_POST['btnprofile']))
{
if($_FILES['profilegallery']['name']!=""){
$res1 = $objdjs->upload_file($_FILES['profilegallery'],PATH_PROFILE_IMAGE);
$image->load(PATH_PROFILE_IMAGE.$res1);
$image->resize(46,36);
$image->save(PATH_PROFILE_IMAGE."thumb_".$res1);
$title=trim($_POST['title1']);
$ins = $objdjs->insertprofile($uid,$title,$res1);
$message开发者_C百科Profile="<span style='color:#336600'>Image has been added in profile gallery</span>";
echo "<script>window.location='listprofilegallery.php?ms=true';</script>";
any help will be appricated Thanks
You can try SWFUpload, it does have a customizable progress bar, but this only works with flash. There's also a jQuery plugin called uploadify
The very ugly but fast solution is to put an iframe that refreshes itself.
Why not use Ajax?
You talk about not changing the code (much), so I think the easiest option is (eugh) a flash uploader. When you say "but I cannot use AJAX" I'm going to assume you mean "I don't know how to use it yet". In this case, I'd recommend jQUery and AJAX. You still couldn't have a progress bar (unfortunately), but it will help you learn AJAX.
I think what your asking is basically impossible, when your user would submit the form you would be stuck. Then only way to create some upload progress bar is
- javascript/ajax
- flash
- java applet
What you want to do is impossible with just PHP. PHP is a server-side language that cannot directly effect the page once it has been served to the browser. You would need some Javascript to do this, AJAX really.
There are two good options:
- use swf
- use AJAX
精彩评论