Jump to content

Recommended Posts

I have a problem with upload images when the ending is .JPG capitalized.. I really don't know what causes it to crash but been testing it for some time and it's my retrictions that won't allow it in. Also I'm experiencing that it sometimes deny to upload pictures if the height or width of that image is above 2000. Here's the code:

 

if(($_FILES[$Ufile]["type"] == "image/jpeg" ||

$_FILES[$Ufile]["type"] == "image/jpg" ||

$_FILES[$Ufile]["type"] == "image/pjpeg")

&& ($_FILES[$Ufile]["size"] < 2000000))

 

Thanks in front^^

Link to comment
https://forums.phpfreaks.com/topic/178022-solved-help-uploading-jpg/
Share on other sites

For debugging, add the following code immediately after the first opening <?php tag in your form processing code and post what you get after you submit the form -

 

ini_set("display_startup_errors", "1");
ini_set("display_errors", "1");
error_reporting(E_ALL);

echo "<pre>";
echo "POST:";
print_r($_POST);
echo "FILES:";
print_r($_FILES);
echo "</pre>";

a bit of info handed to me on here the other day may help. strtolower(   

as well the 2000 my be irrelevant, if you are on an online host it may be the file size not image size but if the images are of the same source all 2000 size img will have relative file size. if you have the php gd libs you can simply recreate the image in the same px size and it will have a smaller file size.

Thank you PFMaBiSmAd, for your input, but unfortunately the only output i get when trying is:

POST:Array

(

    [upload] => Upload

)

FILES:Array

(

    [file1] => Array

        (

            [name] => DSC00127.JPG

            [type] =>

            [tmp_name] =>

            [error] => 1

            => 0

        )

 

)

 

Can't really figure out what i'd do with that.. Still can't upload .JPG i can upload an image as long as the ending is .jpg lowercase.

For debugging...

 

Can't really figure out what i'd do with that.

 

Wouldn't something that shows there is an error have significance -

[error] => 1

 

http://www.php.net/manual/en/features.file-upload.errors.php

 

ALL CODE that is responsible for processing user supplied data must check for all possible errors and validate that data before blindly attempting to use that data. Put some error checking into your code so that at least when a file is uploaded that is larger than the upload_max_filesize setting that you output a meaningful user message.

 

And while you are at it, when the size of the uploaded file exceeds the post_max_size setting, the $_FILES array is completely empty and you need to check for that condition as the first validation test - http://www.php.net/manual/en/ini.core.php#ini.post-max-size

when the ending is .JPG capitalized

 

i assumed this was an indication the problem null for images with .jpg

 

 

Also I'm experiencing that it sometimes deny to upload pictures if the height or width of that image is above 2000. Here's the code:

 && ($_FILES[$Ufile]["size"] < 2000000))

 strtolower($_FILES[$Ufile]["type"]

)

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.