daneth1712 Posted August 12, 2009 Share Posted August 12, 2009 Hi, I basically have a script that allows uploads to a personal folder for a user. this part works fine. I am using the below line to create their folder based on their unique ID. This also works fine, well for the first time a user uses this, but if they wanted to upload more stuff to their folder, the script currently is trying to create the folder again, and displaying an error. mkdir("C:/wamp/www/domain/test3/uploads/$id",0777); How do I do a check to see if the folder is already created, and if not, create the directory, and if it is, to place the file within their folder? Any help or pointers are really appreciated. Link to comment https://forums.phpfreaks.com/topic/169890-creating-directory-if-doesnt-exist/ Share on other sites More sharing options...
waynew Posted August 12, 2009 Share Posted August 12, 2009 Hi, See this function. Link to comment https://forums.phpfreaks.com/topic/169890-creating-directory-if-doesnt-exist/#findComment-896251 Share on other sites More sharing options...
daneth1712 Posted August 12, 2009 Author Share Posted August 12, 2009 thanks for that, really helpful! all works great now, used the: if (is_dir($dir)){ and elseif (!is_dir($dir)){ mkdir($dir,0777); Thanks again, always esier when you know what function to use and where to look. Link to comment https://forums.phpfreaks.com/topic/169890-creating-directory-if-doesnt-exist/#findComment-896283 Share on other sites More sharing options...
daneth1712 Posted August 12, 2009 Author Share Posted August 12, 2009 Hi, I am having 2 little issues with saving a URL which has variable values in it into my MySQL db. The line that I need to input is; $path3= "http://www.domain_name.co.uk/test3/uploads/". $id . "\\". $name; This is basically the path, followed by the personal folder which willbe their unique ID, followed by the name of the file. The path in the database doesnt include the '/' between the 'id' folder and the name of the file. Can anyone advise how I can get this to work? My next issue is.... When someone uploads a file which contains a space, the link that I output it as stops where the space is. Is there a simple line of code I can use to make it pick up the space in the filename? This is displayed from the following; $root= "http://www.domain_name.co.uk/test3/"; $path= "uploads\\". $id . "\\" . $name; $path2=$root . $path; echo "<h3>Your file Link Is: </h3><a href=$path2>$path2</a> Any pointers are very welcome and much appreciated! Link to comment https://forums.phpfreaks.com/topic/169890-creating-directory-if-doesnt-exist/#findComment-896473 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.