Won't show 'Failure' messages

In the script I’m using, I moved ‘upload_avatar.php’ and ‘inner_upload_avatar.htm’ from a Folder into the public_html and public_html/templates folder respectively.

They work successfully there. The only thing I changed on ‘upload_avatar.php’ was this:

include_once ('..classes/config.php'); include_once ('..classes/sessions.php');

to this:

include_once ('classes/config.php'); include_once ('classes/sessions.php');

But, the only thing that doesn’t work is the unsuccessful messages.
When an image uploads successfully “Request has been completed” appears.
But when I upload a non-image file type, or file too large, I see nothing.

The script before I moved it shows" File dimensions error", or “File type not allowed”. I’m stumped as to why those messages don’t appear.

I’ve attached upload_avatar.php. If you could help me figure out why this is the case, or suggest a simple work around, I’d greatly appreciate it. (Also, I know this code is old). Thanks.


upload_avatarPhp.txt (12.6 KB)

Before looking thru your code, are both the “config.php” and “sessions.php” files self-contained? Do they require libraries or
other modules? What I mean is that you move a page to a new folder, you have to not only change files that call those, but,
also, if they have pointer to other files, too. Maybe you just have a line in one of those files that point to some and you need
to add the " …/ " to those links, too.

If they are self-contained meaning not needing any other files, then, it odd they would be broken by moving them.

DOH! ! ! Sorry, just noticed you used just " … " NOT " …/ "… Perhaps that is the issue!

Further comments on the code which I just peeked at. You use a ton of die() functions. These should only be used for
testing first drafts of pages. If you use them, it stops the PHP processing at that point and you see no errors at all.

Also, you suppress a lot of your error messages using @ … This hides important errors and really should never be used
in a PHP script unless you do not want to debug it correctly. Normally, you check for functions in your code and set an error
variable and depending on it’s content, you display an error, you don’t just stop server processing.

You can turn on all error messages for testing by adding these lines to the top of the page:
error_reporting(E_ALL);
ini_set(“display_errors”, 1);
Remember, you do NOT want to use these on live sites. Instead, you should create an error reporting system so that the
ADMIN of the site receives an email with the error and the user gets a stripped down version of the error so they can try a
second time to process their data.

Hope this helps…

Sponsor our Newsletter | Privacy Policy | Terms of Service