Uploading .jpg is OK .JPG is not..?

I’m writing a photo up-loader, if in my form I browse to xxx.jpg and submit it, it up loads fine and the $_FILES array is populated with data as expected. I can then write it from the temporary location to the gallery.

print_r ($_FILES); produces

Array ( [upload] => Array ( [name] => xxx.jpg [type] => image/jpeg [tmp_name] => /tmp/phpbsvDlA [error] => 0 [size] => 91662 ) )

BUT when I upload a file with .JPG (my client’s camera labels files .JPG not .jpg) as the suffix, the $_FILES array is not fully populated, so I can’t then save the file server-side. As you’ll see below, [error] is set to 1, [type] is set to tmp_name and [size] is set to 0.

print_r ($_FILES);
Produces
Array ( [upload] => Array ( [name] => yyy.JPG [type] => [tmp_name] => [error] => 1 [size] => 0 ) )

I’ve set the Form Action to <form action=“formChecker.php” name=“photoUploadForm” method=“POST” enctype=“multipart/form-data”>

Much ‘Googling’ has failed to find a way 'round this. I could tell the client to rename pics from .JPG to .jpg before using the form to upload them, but I can’t believe that there is such a fundamental case sensitive oopsie in PHP (5).

Any help would be welcome!

Thanks

Yeah, I was going to ask if you tested totally separate files to conclude that the extension was the problem. Your .jpg would have worked renamed to .JPG and the clients file would have failed renamed to .jpg

Rats! I hadn’t realised that the customer’s .JPG files were bigger than my .jpg test files…

I assumed ( yes, I know, RTFM Colin! ) that error 1 simply meant failure.

Thank you very much for clearing this up for me.

The server’s php.ini…

;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;

; Whether to allow HTTP file uploads.
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
;upload_tmp_dir =

; Maximum allowed size for uploaded files.
upload_max_filesize = 2M

Colin :blush:

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

:cool: