Jump to content

[SOLVED] mkdir - possible to make a directory outside of the folder the script is in?


fireice87

Recommended Posts

Hey

My file structure is as follows

 

Site\

    Images\

              Large_product_image

              Small_product_image

    Includes\

    Scripts\

 

Im trying to use mkdir in a script that is within the scripts folder. The directory im trying to create is Images\Small_product_image\$prod_id.

Here is the script to make the directory

 

<?php
mkdir("\Images\small_product_image\$prod_id");
copy($_FILES['$thumb'], "/Images/small_product_image/$prod_id/$thumb");
?>

I've tried mulitple combinations (as in file paths) but keep getting file exsist error.

can create a folder with in the same folder the script is in fine.

 

Any help would be great, thanks

 

   

You're using an absolute file path there which means it'd be at /root/images instead of your website's root directory.  Also, you can only create folders that apache has access to edit.  Try using relative paths, and if that doesn't work, check permissions.

<?php
mkdir("../Images/small_product_image/$prod_id");
copy($_FILES['$thumb'], "/Images/small_product_image/$prod_id/$thumb");
?>

 

use rename() to physically move files, unless you want to make a duplicate..

Hey

Thanks that works great sorry for taking awhile to reply had to look up the diffrence betwenn relative paths and absolute i had a general idea but didnt know about things like the '..' to move up a directory. thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.