Link to home
Create AccountLog in
Avatar of sachin_dba
sachin_dbaFlag for India

asked on

PHP photo upload issues

We are facing issues while uploading photos.

We receive photos from many different vendor for our site which is under development. Most of the pictures we are able to upload but few photos provided by 2 vendors are not uploading and appearing black on thumbnails.

I have added few sample pics. Can you please have a look if there is some format issues.

I have also change file names and resize but nothing working.

Any suggestion?
Avatar of DrDamnit
Flag of United States of America image

There doesn't appear to be anything wrong with these jpegs. You said you're making thumbnails... that maybe where the issue is. What are you doing to create the thumbnails?
NTF* here - Are the file uploading correctly?  The $_FILES['error'] field should contain a zero.  If the files are uploaded and stored correctly, something else must be amiss.

* No Trouble Found
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of sachin_dba


Thanks for the details. I have forwarded the details to my development guys. I shall get back to you in case of more questions.
Worth noting the code is missing a final ?> which should be on line 203
code is missing a final ?>
Unless it is required by following HTML, the Zend coding standard is explicit about omitting the final ?>.  There are a lot of reasons for this, and it is considered a best practice to avoid using the close-PHP tag.
Learn something every day.
Here's an example of how it can bite you.  Consider this simple two-line script.

<?php $x = 3; ?>
<?php session_start(); /* etc etc... */

In this simple code example, PHP is stopped and resumed immediately, right?  Well, not exactly.  There is a single invisible new-line character after the close-PHP tag, and this invisible new-line character gets sent to the browser.  A cascade of odd behavior follows.  

It is a law of HTTP that all headers must come first and be completed before any browser output whatsoever, even including invisible white space.  Cookies are part of the HTTP headers.  PHP session_start() uses cookies to connect the client to the stateful information that is kept on the server.  Thus the session_start() function will fail and the PHP session will not work in subsequent page loads.  You can imagine how many programmers have been slapping their foreheads over this kind of thing!  So I just avoid the close-PHP tag if at all possible -- too many things can go wrong.
I notice though that at Zend: PHP Formatitng

it says "... For files that contain only PHP code, the closing tag ("?>") is never permitted.  ..."

Which of course this code is not.
Our posts crossed, thanks for the extra info. I can see that what you say makes a lot of sense.
Right.   I'm not 100% wedded to the Zend standard, but I take it as good advice ;-)
Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Thanks for your replies. There are still vacation in India and my development team will join from Monday.

I will update the post according.

What was wrong with the answers?  What did you not get that you expected?  

Please review the EE grading guidelines and explain why you marked the grade down instead of asking us for additional help.

Thank you, ~Ray
@sachin_dba, I'm flattered by the points allocated to me but I can't help feeling that the buk if not all of the points should go to Ray_Paseur