close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues


Creating directory/folder based on name of file uploaded

Thread began 12/04/2012 5:53 pm by cal114936 | Last modified 12/05/2012 3:56 pm by Jason Byrnes | 351 views | 1 replies |

cal114936Beta Tester

Creating directory/folder based on name of file uploaded


Hoping someone might be able to help. I don't know if this is the best way to accomplish what I want or not.

I want to be able to create a directory/folder and upload files to that folder based on the first part of the image's filename.

Ex. The file name might be... 2012-southwick-national_smith_0146.jpg

I want to have a directory/folder created as /2012-southwick-national/

To do this I need to strip the "_smith_0146.jpg" from the filename. Any help with the regular expression for "dirString" to do this. I only have it stripping the .jpg

Here is what I have for the coding so far...

$photoName=((isset($_FILES["photo1"]))? preg_replace('/.[^.]*$/', '', $_FILES["photo1"]["name"]) :"");

$dirString = '';
$dirString = preg_replace('/.jpg/', '', '$photoName', -1, $dirString);
// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "../$dirstring/",
'FileName' => "[FileName]",
'DefaultFileName' => "",
'ResizeType' => "0",
'ResizeWidth' => "0",
'ResizeHeight' => "0",
'ResizeFillColor' => "" );
// WA_UploadResult1_1 End
// WA_UploadResult1 Params End

Sign in to reply to this post

Jason ByrnesWebAssist

what is the criteria for what part of the file name to keep? There is not really enough information.

are you trying to keep the first x number of characters in the name?

or using another method to determine what to keep?

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...