Jump to content

[SOLVED] Unable to open directory ?


dbillings

Recommended Posts

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>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.