Re: [PHP] Pictureupload

2005-11-04 Thread Georgi Ivanov
On Thursday 03 November 2005 19:12, twistednetadmin wrote:
My advise is not to use $_FILES['img']['type'] or use it with some switch 
statement.
Different browsers send different mime types for same image format. For 
example on mozila you have image/png on IE you have image/x-png (or vise 
versa)
Also the are different mimes for JPEG
image/jpg
image/jpeg
..
image/gif
image/x-gif


You better see what is the type of the image when the error occurs.


 The errormessage is from this part of the script.

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

 So it seems that the file is wrong type or size, but as it works with the
 same picture from my own computer that is odd.

 The timeout part I have to check before I answer to, but I have 4mb
 connection and the last user it failed for has a 2mb connection. 300kb
 shouldn't make the script time out? Or could it? Where do I check the
 timeout settings btw? PHP.ini?
 Or can I run phpinfo() on it?

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



RE: [PHP] Pictureupload

2005-11-03 Thread Jay Blanchard
[snip]
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.
[/snip]

What error message do they get?

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



Re: [PHP] Pictureupload

2005-11-03 Thread Richard Davey
Hi twistednetadmin,

Thursday, November 3, 2005, 4:50:33 PM, you 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.

 form name=guildimage_upload method=post action=?php
 $_SERVER['PHP_SELF'] ? enctype=multipart/form-data





 table class=normal border=0 align=center
 tr
 td height=200 align=center valign=bottom
 class=holyheader18Screenshot upload/td/tr
 tr
 td align=center colspan=2
 table border=1
 tr
 td
 Only pictures with the .jpg extension and size 300kb or less will be
 uploaded!br
 Imagenames should not contain quotes or any special signs!!br

 /td
 /tr
 /table
 /td
 /tr
 tr
 td
 File:nbsp;nbsp;nbsp;nbsp;nbsp;

 input type=hidden name=MAX_FILE_SIZE value=30
 input type=file name=guildimage


 /td
 /tr
 tr
 td

 Comment:
 input name=guildimage_comment type=text size=40 maxlength=40

 /td
 td
 input type=submit name=submit value=Summon
 /td
 /tr
 /tr
 tr

 td height=160 colspan=2 class=maintext valign=top


 ?php
 chmod(/guildimages/, 0777);
 ##
 ###Uploads the image and checks if the image exists already###
 ##

 if (isset($_POST['submit'])) //If you push the submit-button
 {

  $sysfolder=/guildimages/;
 $filename=.$_FILES['guildimage']['name'].;

 if (file_exists($sysfolder . $filename)) //If the filename exists.
 {

  echo Filename exists or no file selected. Please rename the file or select
 a file;

 }

  elseif ($_FILES['guildimage']['type'] == image/jpeg) //And if the image
 is .jpg less or equal 300kb...
 {






 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



  $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

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

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

 }
 }

?

 /td
 /tr
 /table

 /form

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

How large was the image? Could it be that the script is timing out
during an upload? I recently had to change the max_input_time value on
one site because the uploads were so large they kept timing the script
out, yet some people (on really fast connections) could upload just
fine.

Cheers,

Rich
-- 
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

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



Re: [PHP] Pictureupload

2005-11-03 Thread twistednetadmin
The errormessage is from this part of the script.

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

So it seems that the file is wrong type or size, but as it works with the
same picture from my own computer that is odd.

The timeout part I have to check before I answer to, but I have 4mb
connection and the last user it failed for has a 2mb connection. 300kb
shouldn't make the script time out? Or could it? Where do I check the
timeout settings btw? PHP.ini?
Or can I run phpinfo() on it?


RE: [PHP] Pictureupload

2005-11-03 Thread Jay Blanchard
[snip]
The timeout part I have to check before I answer to, but I have 4mb
connection and the last user it failed for has a 2mb connection. 300kb
shouldn't make the script time out? Or could it? Where do I check the
timeout settings btw? PHP.ini?
Or can I run phpinfo() on it?
[/snip]

Check your php.ini as well as your httpd.conf (Apache) for timeout values.
Remember to restart your web server after you have made and changed settings
in either of these files.

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