Jump to content


Photo

Showing image during query


  • Please log in to reply
1 reply to this topic

#1 CanMan2004

CanMan2004
  • Members
  • PipPipPip
  • Advanced Member
  • 254 posts

Posted 21 September 2006 - 01:39 PM

Hi all

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

<?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;

				}
}

?>

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

<? print "timer.gif"; ?>

just after

<?php
session_start();
include ("db.php");

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

then it doesnt load the

<? print "timer.gif"; ?>

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

#2 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 21 September 2006 - 01:53 PM

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
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users