473,500 Members | 1,605 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

imagejpeg() unable to write to file: "is a directory"

Markus
6,050 Recognized Expert Expert
I'm adding to my script a section that allows a thumbnail to be created and saved. I get this error:
Expand|Select|Wrap|Line Numbers
  1. Warning: imagejpeg() [function.imagejpeg]: Unable to open '../uploads/thumb/' for writing: Is a directory in /home/.gobbles/mahcuz/mahcuz.com/upload/uploaded.php on line 129
And this is some of the code from the page:
Expand|Select|Wrap|Line Numbers
  1. /* New code for thumbnails. Will on work if user selects "create thumb on upload" on the upload page */
  2.     //check to see if checkbox is selected
  3.     if(isset($_POST['thumbBox'])){
  4.     // Load image and get image size
  5.         $img1 = "../uploads/mahcuz_".$uploadedImg;
  6.         $orgimg = imagecreatefromjpeg($img1);
  7.         $width = imagesx($orgimg);
  8.         $height = imagesy($orgimg);
  9.         // Setting new width and height for thumbnail size
  10.         $newwidth = 100; //any size as you wish
  11.         $newheight = floor($height*($newwidth/$width));
  12.         // Creating new temporary image
  13.         $tmpimg = imagecreatetruecolor($newwidth, $newheight);
  14.         // Copy and resize old image into new image
  15.         imagecopyresized($tmpimg, $orgimg, 0, 0, 0, 0, $newwidth, $newheight, $width, $height );
  16.         // Save thumbnail into a file
  17.         $path = "../uploads/thumb/"; // <<<< this is line 129 !
  18.         imagejpeg($tmpimg, $path.$img) or die("error");
  19.         $thumbAlert = "Thumbnail created succesfully. Please use the code provided (on the right) to link to the 
  20.  
  21. thumbnail of your uploaded image";
  22.     }
  23.  
  24. /* end code for thumbnails */
  25.  
The created thumbnails are intended to be saved in a directory - root - uploads/thumb/

Not sure what the problem might be. It says unable to write, could it be the file permissions? I've got it set to 777

Thanks :)
Oct 13 '07 #1
6 6784
ak1dnar
1,584 Recognized Expert Top Contributor
Problem is with the second parameter for this function.
Expand|Select|Wrap|Line Numbers
  1. imagejpeg($tmpimg, $path.$img)
You have to set the path correctly.
Oct 13 '07 #2
Markus
6,050 Recognized Expert Expert
Problem is with the second parameter for this function.
Expand|Select|Wrap|Line Numbers
  1. imagejpeg($tmpimg, $path.$img)
You have to set the path correctly.
I'm not sure it is, i have the exact same coding on a test i have on my locahost (computer xampp thing) and it works just fine >_>
Oct 13 '07 #3
pbmods
5,821 Recognized Expert Expert
Changed thread title to better describe the problem (did you know that threads whose titles do not follow the Posting Guidelines actually get FEWER responses?).
Oct 13 '07 #4
ak1dnar
1,584 Recognized Expert Top Contributor
As error describes you can't write down your thumbnail to a directory ilke this;
../what_ever_dir/
It should be a new image path like;
../what_ever_dir/new_thumb_location.jpg

And what about "$img" and "$img1" variables on your scripts. do they suppose to contain the same values or do they having different values. because I didn't see any value for $img variable, yet.
Oct 13 '07 #5
Markus
6,050 Recognized Expert Expert
As error describes you can't write down your thumbnail to a directory ilke this;
../what_ever_dir/
It should be a new image path like;
../what_ever_dir/new_thumb_location.jpg

And what about "$img" and "$img1" variables on your scripts. do they suppose to contain the same values or do they having different values. because I didn't see any value for $img variable, yet.
Awesome! What i was doing was on the right tracks but i'd forgotten to change the name of the variable when i'd copied it from my other file :D

Thanks a bunch

Expand|Select|Wrap|Line Numbers
  1. $path.$img /* which would join the path and img name to create thumb/img.jpg was supposed to be /*
  2. $path.$uploadedImg // as $uploadedImg is the correct variable :D
  3.  
Oct 13 '07 #6
ak1dnar
1,584 Recognized Expert Top Contributor
You are welcome ! Postback anytime. Good luck...
Oct 13 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

235
11490
by: napi | last post by:
I think you would agree with me that a C compiler that directly produces Java Byte Code to be run on any JVM is something that is missing to software programmers so far. With such a tool one could...
3
2151
by: Stinky Pete | last post by:
I've mananged to get Access Run-time working on a Win 98 PC. I was stoked at that achievement, however I'm now stuck in that the files are opening Read only. That is, I can view all the records...
2
3417
by: mark | last post by:
How do I detect that a particular form element is a file upload or if the file upload has worked? In the Python cgi module documentation I found suggested code... form = cgi.FieldStorage()...
5
2035
by: Jared | last post by:
I'd like to display a "please wait while your file is uploading" page immediately after someone uploads a large-ish file. I know I could make something really slick with DHTML, or even something...
94
30184
by: Samuel R. Neff | last post by:
When is it appropriate to use "volatile" keyword? The docs simply state: " The volatile modifier is usually used for a field that is accessed by multiple threads without using the lock...
2
1463
by: =?Utf-8?B?cGVsZWdrMQ==?= | last post by:
i am trying to load diffrent types of pictures like jpg/png/.... the file is being uploaded but i cant after it see the file (i try to open it and get the message that "preview cant be viewed" ...
30
2249
by: GeorgeRXZ | last post by:
Hi Friends, I have some questions related to C Language. 1What is the difference between the standard C language and Non standard C language ? 2which is better C Lanugage, C under Linux/...
4
4041
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 with Apache 2 on Fedora Linux. I have a page, which contains (roughly) $sub_cat_name_arr = split(",", trim($_REQUEST)); foreach ($sub_cat_name_arr as $sub_cat_name)...
2
4449
Haitashi
by: Haitashi | last post by:
<cfinvoke component="Alert" method="send" returnvariable="success"> <cfinvokeargument name="oFusebox" value="#myfusebox#" /> </cfinvoke> The component called Alert works if it's in the same...
0
7136
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7182
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7232
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6906
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4923
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4611
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3106
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
672
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
316
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.