0

Hi hope someone can help me
i have the folowing code

$weinachtfeier = $_POST['aname'];
$mapbeschrijving = $_POST ['expl'];

$slides="slides";
$thumbs="thumbs";

	  $new_height1=100;
	  $new_width1=66;
		
		$new_height=66;
		$new_width=100;
		
     $allowed_types = array( 
     'image/pjpeg', 
     'image/jpg',
     'image/png', 
     'image/jpeg'); 
$imagesize = $_FILES['pic']['size'];
		$imagetype = $_FILES['pic']['type'];
       $imagefile=$_FILES['pic']['name'];
	   	if(in_array($_FILES['pic']['type'], $allowed_types)) 
     {	 
       copy ($_FILES['pic']['tmp_name'], $_FILES['pic']['name']) or die     ("Could not copy");
		 $imagesize = $_FILES['pic']['size'];
		$imagetype = $_FILES['pic']['type'];
       $imagefile=$_FILES['pic']['name'];
	   
       list($width, $height) = getimagesize($_FILES['pic']['name']);
			
		 
			if ($_FILES['pic']['type'] == "image/png" )
			{
			
			
			if ($width<=$height){
				
				$image_p1 = imagecreatetruecolor($new_width1,$new_height1);
				$img = @imagecreatefrompng($imagefile);
				imagecopyresampled($image_p1, $img, 0, 0, 0, 0, $new_width1, $new_height1, $width, $height);
				$thename=$_FILES['pic']['name'];
				$thenames="thumb$thename";
							
							
							$location1=("$mapbeschrijving/$slides");
						$location=("$mapbeschrijving/$thumbs");
							imagepng($img,$location1, 9);	/* this is line 82 */			
							imagepng($image_p1,$location, 9);	/* this is line 83 */		
					
									
				}
	
				if ($width>=$height){
				
				$image_p1 = imagecreatetruecolor($new_width,$new_height);
				$img = @imagecreatefrompng($imagefile);
				imagecopyresampled($image_p1, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
				$thename=$_FILES['pic']['name'];
				$thenames="thumb$thename";
					
							
						
							
						$location1="$mapbeschrijving/$slides/$thename";
						$location="$mapbeschrijving/$thumbs/$thenames";
						imagepng($image_p1,$location, 9);
						imagepng($img,$location1, 9);
						unlink($thename);
											
								
					
									
				}}

but i have the folowing errors

Warning: imagepng() [function.imagepng]: Unable to open '1/slides' for writing: Permission denied in C:\xampp\htdocs\Template1\kg_narrengilde_foto_albums\Weinachtfeier\login\loggedin\FotoAlbenweinachtfeier\uploadimage.php on line 82

Warning: imagepng() [function.imagepng]: Unable to open '1/thumbs' for writing: Permission denied in C:\xampp\htdocs\Template1\kg_narrengilde_foto_albums\Weinachtfeier\login\loggedin\FotoAlbenweinachtfeier\uploadimage.php on line 83


How can i fix this

if i chmod("$location1", 0755);

I have the same errorr

what can i do about it

Thank in advice John

3
Contributors
9
Replies
10
Views
6 Years
Discussion Span
Last Post by johnnyd1963
0

What are the locations you're trying to write to?

1/thumbs ??

0

I believe the chmod command will only work on a Linux-type OS's whereas you're using XAMPP for Windows.

1. Navigate to this directory $mapbeschrijving/$slides 1/slides or whatever it is (The directory you are attempting to write the file to),
2. Right click on directory -> select properties -> you should be able to edit the permission settings of this directory. (I am using Windows 7, there's a tab called 'Security' where I can change the write permissions of that directory)
3. Enable write permissions
4. Retest and post back the result

Edited by nonshatter: n/a

0

well inthis case yes the folder is 1/thumbs and 1/slides

the code to create the folders is

$weinachtfeier = $_POST['aname'];
$mapbeschrijving = $_POST ['expl'];
$slides="slides";
$thumbs="thumbs";
if ($mapbeschrijving == ""){
echo "geen beschrijving";
die;
}
else


 
	  $new_height1=100;
	  $new_width1=66;
		
		$new_height=66;
		$new_width=100;
		
     $allowed_types = array( 
     'image/pjpeg', 
     'image/jpg',
     'image/png', 
     'image/jpeg'); 
$imagesize = $_FILES['cover']['size'];
		$imagetype = $_FILES['cover']['type'];
       $imagefile=$_FILES['cover']['name'];
	   	 
	 
     if(in_array($_FILES['cover']['type'], $allowed_types)) 
     {	 
       copy ($_FILES['cover']['tmp_name'], $_FILES['cover']['name']) or die     ("Could not copy");
		 $imagesize = $_FILES['cover']['size'];
		$imagetype = $_FILES['cover']['type'];
       $imagefile=$_FILES['cover']['name'];
	   
       list($width, $height) = getimagesize($_FILES['cover']['name']);
			
/*----------------------------------------------------------------*/		 
			if ($_FILES['cover']['type'] == "image/png" )
			{
			if ($width<=$height){
				
				$image_p1 = imagecreatetruecolor($new_width1,$new_height1);
				$img = @imagecreatefrompng($imagefile);
				imagecopyresampled($image_p1, $img, 0, 0, 0, 0, $new_width1, $new_height1, $width, $height);
				$thename=$_FILES['cover']['name'];
				$thenames="thumb$thename";
				if (file_exists($mapbeschrijving)) {
					
					echo"
		 <form action=albums.php>
		 <table width='400px' height='200px' bgcolor='yellow'>
		 <tr>
		 <td align='center' style='color:red;' >
		 Das Album mit dem Namen $mapbeschrijving existiert bereits.<br>Bitte geben Sie eine andere Beschreibung.<br><br>
		 *Wenn Sie fertig sind auf abmelden klikken.&nbsp;&nbsp;<b><a href='logout.php'>Abmelden</a></b>
		 </td>
		 </tr>
		 <tr>
		 <td align='center'><br>
		 <input type='submit'value='zurück. '><br><br>
		 </td>
		 
		 </tr>
		 
		 </table>
		  ";		
    
} else {						
						if (isset($_POST ['expl'])) {
							
						if(mkdir("$mapbeschrijving", 0777)){ if (mkdir("$mapbeschrijving/$slides", 0644)){ if (mkdir("$mapbeschrijving/$thumbs", 0777)){
						include "album_angemacht.php";
							} }}
							else {
						echo "Er is iets niet goed gegaan.";
								}
						$location1="$mapbeschrijving/$slides/$thename";
						$location="$mapbeschrijving/$thumbs/$thenames";
						imagepng($image_p1,$location, 9);
						imagepng($img,$location1, 9);
						unlink($thename);
											
						include "iffileexist.php";			
						}
									}
				}
0

Okay, you will need to apply permissions to the top-level directory to which you wish to write a new folder to.

E.g. If you're attempting to write to C:\xampp\htdocs\1\slides
Then you will need to apply write permissions to the C:\xampp\htdocs directory

0

oke thank you that works great

but now i have another problem.

i uploaded all the files

The folder what i created is working perfect
but when i add another image into the slides folder and thumb folder there is no image only i see on my screen

����JFIF��:CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 9
��CY=CNC8YNHNd^Yi�

and so on

How is that possible ?
there where i create the two folders there are in both folders 1 image.
i'ts just going wrong when i put another image and thumb into both folders.

thanks in advice John

0

Hmm. Looks like it's something to do with the content-type in your page.

I think if you send the following header before outputting your image that will do the trick - you need to tell the browser that you are sending image data and not anything else.

header('Content-Type: Image/JPEG');

This thread may be of some help

Edited by nonshatter: n/a

0

i Have fixed that by myself i had a misstype.

Only the new images are not in the folder thumb and slides and thats
what i do not understand

0

Have you checked your apache log file for hints/error messages?

The log file should be located at:

C:\xampp\apache\logs\error.log

It usually provides more descriptive error messages and will save endless hours of debugging/smashing your head against the screen.

0

in C:\xampp\apache\logs\error.log

ther i have no errors from the last 3 hours

But i have fixed it only there was another little problem
there was a copy of the image in the main directory
But i done this with unlink($thename);

Thanks for your help

Many greetings John

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.