//index.php 
$img_dir ="C:/xampp/folders/img/*.jpg"; 
         $thumb_width = 100; 



            // Open a known directory, and proceed to read its contents   
         $scan= glob($img_dir); 
            foreach($scan as $image) {   


              $im= imagecreatefromjpeg($image); 
             $img_width = imagesx($im); 
             $img_height=imagesy($im); 
            $thumb_height= floor ($img_height *($thumb_width/$img_width)); 
            $new_img=imagecreatetruecolor($thumb_width,$thumb_height); 
            imagecopyresized($new_img, $im, 0,0, 0, 0, $thumb_width, $thumb_height, $img_width, $img_height); 
            $thumb_path = "C:/xampp/folders/thumbs/"; 
            imagejpeg($new_img,$thumb_path); 
}  

The error message

Warning: imagejpeg(C:\xampp\folders\thumbs): failed to open stream: Permission denied in C:\xampp\folders\index.php on line 32
he destination file has read and write permissions! Whats wrong with my code?

( I have used both / and \ slashes for file paths, and I still get the same error.)

The imagejpeg() function tries to create a JPEG file in the given directory. If the permissions for that directory are set so that an image cannot be created in it, you will get an error such as the one you are currently getting. Permission denied simply means that the server has no rights to write to the target directory.

Regularly you fix such an issue by chmodding the target directory. In FileZilla you can do this by right clicking the folder and clicking "permissions" (I think). Try setting it to 755, or 777 if that doesn't work. Be warned however that the last enables anyone to write to the folder (not an expert on this subject though, so I can't help you any further than this).