Quick fix for problem uploading images in phpAdsNew

I was installing a copy of phpAdsNew on a server and ran into a problem where the uploaded images were not saving to the specified local folder on the server.  Searching for the answer was a nightmare, as the forums for the phpAdsNew is terrible.

Many of the threads I loaded included moderators yelling at the original posters that the issue was already addressed and told them to search harder.  Granted I know how fustrating it is when you hear the same question again and again, I also believe there is no such thing as a bad question, now matter how many times it is asked by different people.  My breaking point is when I hear the same question from the same individual multiple times.   Anyway, I never found the actual solution to the problem but I gathered helpful hints which lead me to find a solution.

One of the posts suggested removing the @  in front of all the functions and turning error reporting on for the web site.  I did this and still received no error output.  I was completely stumped.

Synopsis
Once I found that others were able to solve the problem by either reverting back to an older version of PHP or by installing on a different server with an older version of PHP, I decided to look specifically at how the uploads are being handled.  I found the banner-edit.php script was using the $HTTP_POST_FILES PHP global variable.  This global variable was changed in PHP version 4.0.3 to $_FILES.

Solution
To solve the problem, I added the following two lines of code near the top of the file.  It does not have to be placed at the top of the script, but it needs to be inserted before the use of the $HTTP_POST_FILES array is used in the code.

[PHP]
if( isset($_FILES) && !isset($HTTP_POST_FILES) )
$HTTP_POST_FILES = $_FILES;
[/PHP]

I am not exactly sure why they are using $HTTP_POST_FILES variable.  I would presume if anyone was using that old of a version of PHP then they have other security issues to deal with and shouldn’t even allow file uploads. Hopefully the phpAdsNew folks will switch to the $_FILES array and soon before others get frustrated and end up using some other similar product.

Leave a Reply

Your email address will not be published. Required fields are marked *