Jump to content

creating directory if doesnt exist


daneth1712

Recommended Posts

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

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!

 

 

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.