Jump to content


Photo

messages displayed to browser for image uploading


  • Please log in to reply
9 replies to this topic

#1 paulgc34

paulgc34
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 04 July 2006 - 06:29 PM

using this code for image uploads:
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="pictures[]"/>
<input type="file" name="pictures[]"/>
<input type="file" name="pictures[]"/>
<input type="submit" value="Send Photos >>"/>
</form>
<?php
foreach ($_FILES["pictures"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["pictures"]["tmp_name"][$key];
$name = $_FILES["pictures"]["name"][$key];
move_uploaded_file($tmp_name, "data/$name");
}
}
?>

How do I print a "successful" message to the browser when it's done uploading and is there a way to dispay a "UPLOADING" MESSAGE WHILE IT'S IN PROGRESS?

#2 shocker-z

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

Posted 04 July 2006 - 06:36 PM

<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="pictures[]"/>
<input type="file" name="pictures[]"/>
<input type="file" name="pictures[]"/>
<input type="submit" value="Send Photos >>"/>
</form>
<?php
foreach ($_FILES["pictures"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
  $tmp_name = $_FILES["pictures"]["tmp_name"][$key];
  $name = $_FILES["pictures"]["name"][$key];
  move_uploaded_file($tmp_name, "data/$name");
  if (!is_file("data/$name") {
  $error='Image not uploaded';
  }
}
}
if (!$error) {
echo("Successfully uploaded all images");
} else {
echo("ERROR Images have not all been uploaded");
}
?>

No way to show uploading or a less you used javascript to popup a window that says uploading and then when window loaded u close the window by it's name..

Regards
Liam
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#3 SharkBait

SharkBait
  • Members
  • PipPipPip
  • Advanced Member
  • 845 posts
  • LocationMetro Vancouver, BC

Posted 04 July 2006 - 06:38 PM

After you have done all the move_uploaded_file() you could Header() to another page and show a 'Your upload was successful'

As for showing a message saying 'Upload in Progress' I would look at using a javascript popup window or something.

I havent really played with javascript much so I cant show any code, but the idea should get ya in the right direction.

:)

#4 paulgc34

paulgc34
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 04 July 2006 - 07:44 PM

How would I use the header() method. Can anyone show me what the code would be. I cant get the print messages method to work.

#5 Birdman203

Birdman203
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 04 July 2006 - 07:49 PM

header('Location: url');

#6 paulgc34

paulgc34
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 04 July 2006 - 08:14 PM

I'm adding the:

header("Location: http://www.escortlobby.com/");

line to the code but it doesnt seem to be doing anything.

#7 paulgc34

paulgc34
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 04 July 2006 - 08:17 PM

I'm getting this error:

Warning: Cannot modify header information - headers already sent by (output started at /home/paulgc34/public_html/uploadphotos.php:6) in /home/paulgc34/public_html/uploadphotos.php on line 259


#8 paulgc34

paulgc34
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 04 July 2006 - 08:19 PM

heres the code:

<?php
foreach ($_FILES["pictures"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["pictures"]["tmp_name"][$key];
$name = $_FILES["pictures"]["name"][$key];
move_uploaded_file($tmp_name, "data/$name");
}
}
header("Location: http://www.escortlobby.com/");
?>

#9 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 04 July 2006 - 08:43 PM

The cause is in uploadphotos.php on or around line 6. Could you post line 3 - 9 here so we can have look.

#10 paulgc34

paulgc34
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 04 July 2006 - 09:06 PM

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>

</head>

<body>




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users