Re: [PHP] Re: Pictureupload

2005-11-03 Thread comex
> if (isset($_POST['submit'])) //If you push the submit-button
Maybe the user pressed ENTER instead of clicking the button.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Pictureupload

2005-11-03 Thread James Benson



twistednetadmin wrote:

I have made this script to upload pictures into a picturegallery on a
website.
The script works just as I expected, but with one huge flaw. It doesn't work
from every users computer.
I can upload pictures with no problem, but another user get's an
errormessage. the other user emailed the picture to me and I could upload it
with no errors.

Here's the script.









Screenshot upload





Only pictures with the .jpg extension and size 300kb or less will be
uploaded!
Imagenames should not contain quotes or any special signs!!








File: 










Comment:
















You may want to also do something like

if(filesize($filename) > 300) {
   echo "File too large";
}








copy ($_FILES['guildimage']['tmp_name'],
"/guildimages/".$_FILES['guildimage']['name']) //Copy the image to
/guildimages
 or die("Could not copy file"); //Or don't if it's wrong size or format




Here you should be using move_uploaded_file() instead of copy()

http://php.net/move_uploaded_file







 $insertSQL = sprintf("INSERT INTO guildimages (guildimage_date,
guildimage_name, guildimage_comment, posted_by) VALUES (NOW(), '%s', '%s',
'%s')",
 ($_FILES['guildimage']['name']),
 ($_POST['guildimage_comment']),
 ($_SESSION['logname']));
 $guildimage_upload = mysql_query($insertSQL) or die(mysql_error());
//insert all info to the DB




You probably want to do some checks above (before inserting), maybe use 
http://php.net/manual/en/function.is-uploaded-file.php






echo "Result:\n";
 echo "Filename: ".$_FILES['guildimage']['name']."\n";
 echo "Filesize: ".$_FILES['guildimage']['size']." byte\n";
 echo "Filtype: ".$_FILES['guildimage']['type']."\n";
 echo "Congrats! It worked!\n";
 }
 else
{

echo "Result:\n";
echo "Now that didn't seem to work... \n
Did you try a wrong format or size? \n
File that failed--> (".$_FILES['guildimage']['name'].")";

}
}

?>







Can anyone see what's wrong? Since it works from some computers and not from
all?



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Pictureupload

2005-11-03 Thread twistednetadmin
As I'm not the serveradmin I have only checked the phpinfo wich says:

mysql.connect_timeout60

default_socket_timeout60

Keep-Alive 300

HTTP_KEEP_ALIVE 300

Timeouts Connection: 300 - Keep-Alive: 15

Wich of these I should work out from and what they all have to say, I'm not
sure of though since I'm quite new to this.

The errormessage is written above James.


[PHP] Re: Pictureupload

2005-11-03 Thread James Benson



twistednetadmin wrote:

I have made this script to upload pictures into a picturegallery on a
website.
The script works just as I expected, but with one huge flaw. It doesn't work
from every users computer.
I can upload pictures with no problem, but another user get's an
errormessage. 



Should we guess the error message or play hang man for it?


Can I have a P please :)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php