fireice87 Posted April 23, 2008 Share Posted April 23, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/102576-solved-mkdir-possible-to-make-a-directory-outside-of-the-folder-the-script-is-in/ Share on other sites More sharing options...
p2grace Posted April 23, 2008 Share Posted April 23, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/102576-solved-mkdir-possible-to-make-a-directory-outside-of-the-folder-the-script-is-in/#findComment-525253 Share on other sites More sharing options...
The Little Guy Posted April 23, 2008 Share Posted April 23, 2008 <?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.. Quote Link to comment https://forums.phpfreaks.com/topic/102576-solved-mkdir-possible-to-make-a-directory-outside-of-the-folder-the-script-is-in/#findComment-525256 Share on other sites More sharing options...
fireice87 Posted April 23, 2008 Author Share Posted April 23, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/102576-solved-mkdir-possible-to-make-a-directory-outside-of-the-folder-the-script-is-in/#findComment-525297 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.