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

filepath variable not working

Guest
Dec 09, 2010 Dec 09, 2010

Hi I have a page builder form and when the user is finished building her page, she can click "Write File" and the file will actually be saved to a particular folder as an html file.  All this worked fine until I wanted to try and save these new files to a network shared folder so that our employer could copy the files over to his pc and review them before uploading to the remote server.

Here is the new file path variable and the path I assigned to it.

<!--- Set Path and File Name --->
<cfset fileExtension = ".html">
<cfset pathToFile = "C:\webdes-pc\newPageFiles">
<cfset fileToWrite = pathToFile & SESSION.fileName & fileExtension>

Here is the original code that worked perfectly.

<!--- Set Path and File Name --->
<cfset fileExtension = ".html">
<cfset pathToFile = "C:\ColdFusion8\wwwroot\replacememntlightbulbs\pageBuilder\">
<cfset fileToWrite = pathToFile & SESSION.fileName & fileExtension>

Is there a reason why I could not write a file to a networked folder? I would have thought there wouldnt have ben a problem with that idea. Thanks for any help in advance!

467
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
Dec 09, 2010 Dec 09, 2010

lol nevermind! As I was typing this post I noticed I didn't have the backslash at the end of my folder name. Sorry for the dumb post!

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
Valorous Hero ,
Dec 09, 2010 Dec 09, 2010
<cfset pathToFile = "C:\webdes-pc\newPageFiles\">

That worked?  That looks like a mapped folder and those usually do not work because ColdFusion runs as a different user then the whomever might have mapped the folder?

What usually works is a UNC path more like "\\webdes-pc\newPageFiles\" after ColdFusion has been configured to run as a domain user that has the permissions to that network path rather than the default "localSystem" user which usually has NO network permissions.

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
Dec 09, 2010 Dec 09, 2010

ilssac wrote:

<cfset pathToFile = "C:\webdes-pc\newPageFiles\">

That worked?  That looks like a mapped folder and those usually do not work because ColdFusion runs as a different user then the whomever might have mapped the folder?

What usually works is a UNC path more like "\\webdes-pc\newPageFiles\" after ColdFusion has been configured to run as a domain user that has the permissions to that network path rather than the default "localSystem" user which usually has NO network permissions.

Actually you might be right. I think I have a folder named webdes-pc in my C drive as well. I had the file path set as \\webdes-pc\newPageFiles\ as you suggested before, but might have not had the last backslash on there either. So I think when I get to work tomorrow I will try this path again. Thanks!

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
Enthusiast ,
Dec 09, 2010 Dec 09, 2010
LATEST

It is a best-practice not to use backslahes in paths. Forward slashes will work on Windows too - and on every platform.

Only when you're for example creating .BAT files, or passing path-containing parameters with CFEXECUTE, you may need backslashes in Windows.

-Fernis

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