Jump to content

Archived

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

paulgc34

messages displayed to browser for image uploading

Recommended Posts

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?

Share this post


Link to post
Share on other sites
<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

Share this post


Link to post
Share on other sites
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.

:)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
I'm adding the:

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

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
heres the code:

[color=red]<?php[/color]
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/");
[color=red]?>[/color]

Share this post


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

Share this post


Link to post
Share on other sites
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.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>

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.