简体   繁体   中英

PHP - GetImageSize()

I'm trying to use the getimagesize() function on an image uploading script. Sometimes, on certain images, I get an error. So I tried to investigate.

I used an image which seems to work, edited it with paint.exe, and saved it as a new jpg image.

When I look at the $_FILES[] , I get this :

Original :

$_FILES : array(2) {
  ["thumb_a_uploader"]=> array(5) {
    ["name"]=> string(8) "1212.jpg"
    ["type"]=> string(10) "image/jpeg"
    ["tmp_name"]=> string(14) "/tmp/phprZ2H8G"
    ["error"]=> int(0)
    ["size"]=> int(90281)
  }

Edited :

$_FILES : array(2) {
  ["thumb_a_uploader"]=> array(5) {
    ["name"]=> string(16) "1212 - Copy.jpg"
    ["type"]=> string(0) ""
    ["tmp_name"]=> string(0) ""
    ["error"]=> int(2)
    ["size"]=> int(0)
  }

And for the edited one, the imagetype was wiped. I have the same problem with a picture taken with a smartphone.

Any ideas ?

You need to pay attention to ["error"] .

["error"]=>
int(2)

 UPLOAD_ERR_FORM_SIZE

Value: 2 ; The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.

Learn more about php file-upload.errors

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM