File permission to PHP uploaded image

In my PHP site I have a script to upload images, see the script below

$uploaddir = $root_path."images/uploaded_images/category/"; 
            $small_file_name = trim($_FILES['cat_image1']['name']);
            $small_file_len = strlen($small_file_name);
            $small_file_ext = strtolower(substr($small_file_name,-4)); // select last 4 characters
            $small_uploadfile = $uploaddir. $_FILES['cat_image1']['name'];  
            if($small_file_len>4 and ($small_file_ext==".gif" or $small_file_ext==".jpg" or $small_file_ext=="jpeg")){
                if ($small_file_ext=="jpeg")
                    $uniqname = uniqid(rand()).".".$small_file_ext;
                    $uniqname = uniqid(rand()).$small_file_ext;
                $thumb_filename1 = "thumb_".$uniqname;  //  store uniqname into database
                $uploadfile = $uploaddir.$uniqname; //uncomment for local testing 
                if (move_uploaded_file($_FILES['cat_image1']['tmp_name'], $uploadfile)) {
                    list($width, $height, $type, $attr) = getimagesize($uploadfile);
                    $max_width = 276;
                    $max_height = 162;
                    $a = new Thumbnail($uploadfile,$max_width,$max_height,$uploaddir.$thumb_filename1,100,'');

                        $frm_server_side_error= $frm_server_side_error."Error in uploading image,";
                $frm_server_side_error= $frm_server_side_error."Image not in gif or jpg format,";


After uploading in to the server its can't be see (I am displaying the thumb image). So I checked the file permission of that image through the FTP and give read permission. Thus image displays. But I give the read and write permission to the category folder and it’s parent folders. How can view the image after uploading (default read permission to the uploading files ie thumb image.)

I noticed that the actual image have read permission but the thumb image doesn't have the read permission. I need to display only the thumb image.


You have used a class Thumbnail to create a thumbnail image. But I guess you have missed to change the file permission in the new thumbnail image. Please check the code in the create() function of the class Thumbnail

Your code formatted poorly here (half is in code format, half not), but it appears you have a comment before the snippet that would copy the file from the temp location to the final location - if that's the case, the file won't exist, and thus won't be viewable.

But I could be wrong - I'm happy to take a second look if you fix the formatting.

Need Your Help

Where should my objects/models live if they contain domain functionality?

oop design-patterns architecture repository domain-driven-design

I've designed my classes using CRC cards and I have a lovely set of objects that contain domain/business logic AND data (properties). Some of the classes require saving to and reading from a databa...

c# serial port redirection

c# windows-mobile serial-port

Is there a way to, in c# write a serial port redirector? I have an app that is coded to use port 1 (com1:) however, my port on the handheld (Intermec CN50) is always 3. I do not have access to mo...