Jump to content

messages displayed to browser for image uploading


paulgc34

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

:)
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]
<!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>

Archived

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

×
×
  • Create New...

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.