Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

problem creating new dir

Community Beginner ,
Apr 20, 2006 Apr 20, 2006
Hi there,

Here is the scope. If the directory does exist, continue to upload the file otherwise It should create a new directory by his username and upload the file but having problems doing it. here is the code.

1.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Apr 21, 2006 Apr 21, 2006
Thanks JMGibson3,

Big help, I had to tune it a liitle bit to work properly but your code helped. Thanks again. Here is the last code if somebody needs it.

<cfset TempDir= "#application.drivepath##Session.username#">
<cfif NOT DirectoryExists(#TempDir#)>
<cfdirectory directory="#TempDir#" action="create">
<CFFILE ACTION="UPLOAD"
FILEFIELD="File"
DESTINATION="#TempDir#"
NAMECONFLICT="OVERWRITE">
<cfelse>
<CFFILE ACTION="UPLOAD"
FILEFIELD="File"
DESTINATION="#TempDir#"
NAMECONFLICT="OVERWRI...
Translate
Guest
Apr 20, 2006 Apr 20, 2006
Change your CFIF statement to
<cfif IsDefined("TempDir") AND NOT IsDefined("NewDir")>
and see what happens.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 20, 2006 Apr 20, 2006
Nothing changed, any new user I use, I get this error

The specified Directory attribute value d:\Customers\Files\Steve could not be created.
The most likely cause of this error is that the 'd:\Customers\Files\Steve' already exists on your file system. The exception occurred during a cfdirectory action="CREATE".


Still looking at the same dir.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 20, 2006 Apr 20, 2006
I suspect you do not have write permissions on the server.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 20, 2006 Apr 20, 2006
No, I am running on a test server and I am the admin. Now if it doesn't find a dir with that user, it creates ones and he can upload but if he tries again, gets that message. It is trying now to create a new dir everytime and don't look if the dir exists.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 20, 2006 Apr 20, 2006
After your CFELSE, place the following. Perhaps it will shed some light on the issue.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 20, 2006 Apr 20, 2006
+++#TempDir#+++#NewDir#+++<BR>
+++#application.drivepath##Sep##Session.username#+++
??

I didn't even try to put them in
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 20, 2006 Apr 20, 2006
You might learn something about the values of these variables. That's what you want, isn't it?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 20, 2006 Apr 20, 2006
Per latest code you're basing your decision on whether or not to create a new directory on the Existence of a local variable rather than its value. Try replacing IsDefined("TempDir") with DirectoryExists(TempDir). Also YOU may have rights to everything but what really counts is what the account under which the Cold Fusion Service is running has rights to. Visit Services, right click, properties, etc., until you get to the Logon tab.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 20, 2006 Apr 20, 2006
don't mind if I ask, never seen this in cf
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 20, 2006 Apr 20, 2006
See below. I hope your next post contains the results of the CFOUTPUT.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 20, 2006 Apr 20, 2006
Again, I can add a new directory if the user login for the first time and upload the file succesfully but if I try again with tha same user I get this error.

Error Occurred While Processing Request
The specified Directory attribute value d:\Customers\Files\Temp could not be created.
The most likely cause of this error is that the 'd:\Customers\Files\Temp' already exists on your file system. The exception occurred during a cfdirectory action="CREATE".

The Error Occurred in D:\WWW\Clients\upload.cfm: line 61

59 : <!--- <CFSET Session.username = #getinfo.username#> --->
60 : <cfset NewDir= "#application.drivepath#">
61 : <cfdirectory action="CREATE" directory="#NewDir#" name="#NewDir#">
62 : <cfoutput><CFFILE ACTION="UPLOAD"
63 : FILEFIELD="File"
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 20, 2006 Apr 20, 2006
What's the difference between TempDir and NewDir? Actually, nevermind, I don't really want to know. Say for the sake of convenience a variable, TheDir, has been set to d:\Customers\Files\Steve

<cfif NOT DirectoryExists(TheDir)>
<cfDirectory create........... TheDir ................> <!--- if not already there, create it --->
</cfif>
<cffile Upload...............TheFile..into..TheDir....>

shoud give you what you're looking for right now.
If you want to get into Directory renaming, consult the Help docs, but you'll still need to check if it's there already.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 21, 2006 Apr 21, 2006
LATEST
Thanks JMGibson3,

Big help, I had to tune it a liitle bit to work properly but your code helped. Thanks again. Here is the last code if somebody needs it.

<cfset TempDir= "#application.drivepath##Session.username#">
<cfif NOT DirectoryExists(#TempDir#)>
<cfdirectory directory="#TempDir#" action="create">
<CFFILE ACTION="UPLOAD"
FILEFIELD="File"
DESTINATION="#TempDir#"
NAMECONFLICT="OVERWRITE">
<cfelse>
<CFFILE ACTION="UPLOAD"
FILEFIELD="File"
DESTINATION="#TempDir#"
NAMECONFLICT="OVERWRITE">
</cfif>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources