Jump to content

[SOLVED] copy() permission denied


webent

Recommended Posts

Hi all, I am trying to copy images from one directory on one domain to another directory on another domain, but I get permission denied... I have both directory's permissions set to 777, so I assume it's a chown thing, would that be correct? Here's my code...

 

if (isset($_GET['CATEGORY'])) {
$result = mysql_query("SELECT SKU, PRODUCT_IMAGE, MSRP, PRODUCT_NAME FROM $_GET[PRODUCT_LINE] WHERE CATEGORY = '$_GET[CATEGORY]' LIMIT 10");
    while ($row = mysql_fetch_assoc($result)) { 
                $image = retrieveImage($row[PRODUCT_IMAGE]);
                echo '<img src="' . $image . '" />';
                echo '<br>' . $row[PRODUCT_NAME] . ' - $' . $row[MSRP] . '<br>';
    } 
exit;           
} 

function retrieveImage($image) {
$image = "/home/mainaccount/public_html/supplier/images/$image";
$new_destination = "images/$image";
copy($image, $new_destination);
return;    
}

Link to comment
Share on other sites

644 , that would be my problem then wouldn't it... having some issues with chmod sticking though... I went and re-checked the permissions on the directory that I told you was 777, it was back to 755 ... perhaps I have to ssh in as root and do it, for it to stick, perhaps a Cpanel security issue or something that won't allow non-root users to change permissions...

 

On that subject, I'll have to find the unix command for chmod all the contents in a directory ... I assumed that when you chmod a directory, all contents changed to that value... Unless that goes back to what I originally was saying about how the chmod isn't taking...

Link to comment
Share on other sites

I just tried that, but it didn't change the permissions of the images within the directory, did it from root via ssh...

 

Do you think that it is because my root privileges are in a vps and not a true dedicated, that my abilities to do such functions are limited?

 

Edit: Did it again, using the full path instead of just being in the next up directory and naming the directory... It worked! Buh Yah! Now let's just see if the Copy() works...

Link to comment
Share on other sites

chmod("filename", 0444) , worked for me all the times on different hosts ( mainly using this for log files and it never failed )

you should run it inside php file like this

 

if ( chmod("filename", 0444) ) {

 

        //do stuff here

 

} else {

 

              //error stuff here

 

}

Link to comment
Share on other sites

oki then 7 it is , never whent to deep into this , let me check

 

 

back , it should be "0660" "rw-rw----" , read write for owner and group , or "0760" "rwxrw----"for read write execute for owner and read write for group .

 

 

back once more and gues what 4 is for read hahaha , so my log files never neded 0444 , but 0660

Link to comment
Share on other sites

Actually what I think happened when I first tried to change the permissions like DarkWater instructed me to, I didn't wait long enough... I think it took a while to change permissions for 30,000 images...

 

copy() still does not work, still gives "Permission denied", even changed both directories and all images to 777 

Link to comment
Share on other sites

Tried a completely different route and it doesn't do anything at all...

 

function retrieveImage($image) {
$old_destination = "/home/mainaccount/public_html/supplier/images/$image";
$new_destination = "images/$image";   
//copy($old_destination, $new_destination);

exec("cp -R $old_destination $new_destination");

return;    
}

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.