1

I am getting these errors when trying to upload an image to the server

Warning: getimagesize(../images/image-1Product 320120312100APPLE_IMG_0072.jpg) [function.getimagesize]: failed to open stream: No such file or directory in /home/content/44/8713044/html/admin/Home.php on line 107

Warning: imagecreatefromjpeg(../images/image-1Product 320120312100APPLE_IMG_0072.jpg) [function.imagecreatefromjpeg]: failed to open stream: No such file or directory in /home/content/44/8713044/html/admin/Home.php on line 122

Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/content/44/8713044/html/admin/Home.php on line 128

I know why I am getting the third error because of the 1st and 2nd error, I dont why I am getting warnings for 1 and 2, the folder does exist.

Line 107 - $size = getimagesize($source);

Line 122 - $image = imagecreatefromjpeg($source);

Line 128 - imagecopyresampled($new_image,$image,0,0,$x,$y,$thumb_width,$thumb_width,$width,$height);

If anyone has got any tips It would be much appreciated.

I changed it over to the full path, but got this error URL file-access is disabled in the server configuration

user979331
  • 11,039
  • 73
  • 223
  • 418

4 Answers4

4

This problem is usually solved by reconfiguring the php.ini

allow_url_fopen = On

To do that, you might need to contact your hosting provider.

If you're using Wordpress or any other CMS, it might accure due to a security plugin that's installed. Most security plugins change the .htaccess in order to prevent unauthorized access to url's, directories and files.

check your .htaccess and search for

RewriteRule ^.* - [F,L]

if you find it, remove it (#RewriteRule ^.* - [F,L]) and check if it fixed your problem.

AlonMichaeli
  • 161
  • 1
  • 7
  • By removing it I'm getting 500 internal server error :( again putting those values is again showing 500 internal server. what might be the causes? any help greatly appreciated. – Jay Maharjan Feb 24 '16 at 09:57
0

Try and remove the space from your file name. I had a problem like this once, and I believe removing the space fixed it.

Change:

image-1Product 320120312100APPLE_IMG_0072.jpg)

To:

image-1Product320120312100APPLE_IMG_0072.jpg)
Paul Dessert
  • 6,363
  • 8
  • 47
  • 74
0

your $source variable is point to wrong path ..
if you include a php file in other folder that contains this code , try to use local path like this :

$source='images/image-1Product 320120312100APPLE_IMG_0072.jpg';
$size = getimagesize($source);

don't use '../' if your images folder is in root that first file is there .

M Rostami
  • 4,035
  • 1
  • 35
  • 39
  • if the images folder is not in the root, its on the server, but not in the root – user979331 Apr 25 '12 at 18:21
  • ex:your www folder contains two other folder such as 1-images 2-includes and your index.php . if index.php is include a file in "includes" folder you can not use "../images" to access to images folder on that file.because your first file that will be processed is index.php .maybe it is your wrong . i'm sure that your $source is pointing to wrong path. – M Rostami Apr 25 '12 at 18:28
  • `root/images` & `root/upload` are the folders I want to upload to...the file that is doing the uploading is `root/admin/home.php` – user979331 Apr 25 '12 at 18:36
  • which file contains $source and in which folder? are you using direct url like:"site.com/admin/home.php" ? – M Rostami Apr 25 '12 at 18:52
-1
  1. Try to enter the complete url to route to the image meaning include the http://
  2. Check your rights on the folders meaning : Right 777
Jonathan Römer
  • 629
  • 5
  • 23