Jump to content

Archived

This topic is now archived and is closed to further replies.

CanMan2004

Showing image during query

Recommended Posts

Hi all

I have a php page with a image upload box on it, the code looks like

[code]<?php
session_start();
include ("db.php");

if ($_POST['action'] == "upload")
{

if ($addimage == "") { $upfile = "$rows[logo]"; }

if ($addimage == "")
{
}
else
{
$addimage_name = $random.str_replace(' ', "", $addimage_name);
$upfile = "images/".$rand.$addimage_name;

if (!copy($addimage, $upfile))
{
print "Error";
exit;
}
createthumb($upfile,$upfile,'',100,'');
$upfile = $rand.$addimage_name;

$sql ="UPDATE `data` SET `image`='$upfile' WHERE `id`='".$_POST['id']."'";
@mysql_query($sql, $connection) or die(mysql_error());
exit;

}
}

?>[/code]

the problem is that if the image is big, it can take some time to upload and resize the image.

What I want to do is to display an image on the page while the upload is happening, the image is to show that the file is being uploaded, basically a little animated timer, the problem I have found, is that if I place a

[code]<? print "timer.gif"; ?>[/code]

just after

[code]<?php
session_start();
include ("db.php");

if ($_POST['action'] == "upload")
{[/code]

then it doesnt load the

[code]<? print "timer.gif"; ?>[/code]

until it has completed uploading a file.

Is there a way around this, to display the image as soon as the form is submitted and then to change the image once the script has completed?

Any help would be great

Thanks in advance

Ed

Share this post


Link to post
Share on other sites
look into using AJAX good tutorial on http://www.ajaxfreaks.com as PHP is all parsed before any output is given but with AJAX you can check the status of a page and display an output (e.g. an uploaid in progress image) whilste it's uploading..

regards
Liam

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.