dbillings Posted December 22, 2007 Share Posted December 22, 2007 I recieve the following error: Warning: imagejpeg() [function.imagejpeg]: Unable to open 'C:/wamp/www/thumb/' for writing: Permission denied in C:\wamp\www\image upload\resizeimages.php on line 62 If someone could just point me in the right direction that would be great. <?php if(isset($_REQUEST['submit'])){ $thumbarray = array(); $imagearray = array(); $dir = $_REQUEST['directory']; if(is_dir($dir)) { if ($dh = opendir($dir)){ while (($file = readdir($dh)) !== false) { if(filetype($dir . $file) == "file") { if(exif_imagetype($dir . $file) != IMAGETYPE_JPEG) { echo $dir . $file . " Resize failed not a JPEG image. <br />"; }else{ $tmpname = $dir.$file; echo $tmpname." Type: JPEG <br />"; $filesize = filesize($tmpname); $orig_image = imagecreatefromjpeg($tmpname); list($width, $height) = getimagesize($tmpname); if($filesize > 157286) { // Resize image if it's over 150 kb's. $percent = 157286 / $filesize; $newwidth = $width * $percent; $newheight = $height * $percent; $new_image = imagecreatetruecolor($newwidth, $newheight); imagecopyresampled($new_image, $orig_image, 0, 0, 0, 0,$newwidth, $newheight, $width, $height); } // Generate thumbnail images. $thumbw = 50; $thumbh = $thumbw / $width * $height; $thumb = imagecreatetruecolor($thumbw, $thumbh); imagecopyresampled($thumb, $orig_image, 0, 0, 0, 0, $thumbw, $thumbh, $width, $height); chmod("C:/wamp/www/thumb", 0777); imagejpeg($thumb, "C:/wamp/www/thumb/"); chmod("C:/wamp/www/image", 0777); imagejpeg($new_image, "C:/wamp/www/image/"); } } } closedir($dh); } }else{ echo "The submited directory is invalid."; } } ?> <form method="post" action="<?php $_SERVER['PHP_SELF']; ?>"> Directory<input type="text" name="directory"><br /> <input type="submit" name="submit" value="Submit"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/82809-solved-unable-to-open-directory/ Share on other sites More sharing options...
shocker-z Posted December 22, 2007 Share Posted December 22, 2007 sounds like you need to change the permissions of the directory to full control for your IIS/apache user IIS user is under directory security and apache user is usually the user the service runs under e.g. start > run > services.msc > Apache or Apache2 > properties > [LogOg] Alternativly you could give the group Everyone Full Control Regards Liam Quote Link to comment https://forums.phpfreaks.com/topic/82809-solved-unable-to-open-directory/#findComment-421149 Share on other sites More sharing options...
dbillings Posted December 22, 2007 Author Share Posted December 22, 2007 I am making an effort here and I don't want you to think I'm not searching the web with every effort to figure this out for myself. I have apache by the way and I can't figure out where to give myself full control. I think my user name is Dennis based on the services.msc you gave me. From what I read it appears that I would enter the following bit of code in the httpd.cofig... <Directory "C:/wamp/www/thumb"> UserDir enabled Dennis </Directory> I'm not sure if that has to go anywhere in particular but I added it and my webserver wouldn't start after I did it. I'd really appreciate any additional help you could offer. Quote Link to comment https://forums.phpfreaks.com/topic/82809-solved-unable-to-open-directory/#findComment-421190 Share on other sites More sharing options...
shocker-z Posted December 22, 2007 Share Posted December 22, 2007 Sorry let me explain, it's not the configuration file that needs changing it's the windows permissions. open the folder "C:/wamp/www/" Right click on "thumb" Click Properties Click Security [tab] Click Add Enter Dennis Click OK Put a check in Full control Regards Liam Quote Link to comment https://forums.phpfreaks.com/topic/82809-solved-unable-to-open-directory/#findComment-421215 Share on other sites More sharing options...
dbillings Posted December 22, 2007 Author Share Posted December 22, 2007 I have XP and and it doesn't have a security tab when I click properties. It has general, sharing and customize. It appears hopeless. Quote Link to comment https://forums.phpfreaks.com/topic/82809-solved-unable-to-open-directory/#findComment-421268 Share on other sites More sharing options...
dbillings Posted December 22, 2007 Author Share Posted December 22, 2007 figured it out. I needed to create a name for my file (duh) in my imagejpeg($image, $path.$randomname); Thanks for all the help shocker. Quote Link to comment https://forums.phpfreaks.com/topic/82809-solved-unable-to-open-directory/#findComment-421365 Share on other sites More sharing options...
shocker-z Posted December 23, 2007 Share Posted December 23, 2007 just a not. If you have no security tab, this is because simple file sharing is enabled. To show your security tab (as you will need to do this at certain points of PHP scripting) Open "My Computer" Tools > Folder Options.. > View scroll down to the bottom take tick out of Use simple file sharing (reccomended) Glad that you figured it out for your self Regards Liam Quote Link to comment https://forums.phpfreaks.com/topic/82809-solved-unable-to-open-directory/#findComment-421840 Share on other sites More sharing options...
dbillings Posted December 23, 2007 Author Share Posted December 23, 2007 It doesn't work for Windows Home Edition which I have. I did a web search and I would have to restart my PC in safe mode and logon as administrator to adjust individual file permissions. Gotta love Home Edition. Quote Link to comment https://forums.phpfreaks.com/topic/82809-solved-unable-to-open-directory/#findComment-421909 Share on other sites More sharing options...
corbin Posted December 23, 2007 Share Posted December 23, 2007 cacls can be used in Windows HE for file perms..... It doesn't have a fancy interphace though ;p. cmd whoo whoo! Edit: Bleh guess I'll give an example: mkdir everyone_can_mod_this cacls everyone_can_mod_this /P "Everyone":F Quote Link to comment https://forums.phpfreaks.com/topic/82809-solved-unable-to-open-directory/#findComment-421939 Share on other sites More sharing options...
shocker-z Posted December 23, 2007 Share Posted December 23, 2007 calcs runs with no issues.. once you show it who's boss Bit like women really lol Saying that i do have a kid and a fiancee lol Quote Link to comment https://forums.phpfreaks.com/topic/82809-solved-unable-to-open-directory/#findComment-421941 Share on other sites More sharing options...
corbin Posted December 23, 2007 Share Posted December 23, 2007 Yeah.... I use cacls on my computer with Windows HE a lot.... Anyway, sorry if I got a little off topic, but the whole cacls thing was kinda related ;p. Quote Link to comment https://forums.phpfreaks.com/topic/82809-solved-unable-to-open-directory/#findComment-421942 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.