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

mystery ExpandPath(".")

New Here ,
Oct 23, 2008 Oct 23, 2008
1) I'm trying to save file into the folder - absolute path: c:\coldfusion8\wwwroot\mysite\Images_tools\images. After that I'm trying to set image variable.

2) Action file test.cfm includes only code below and situates in the Images_tools folder.

Code:

<cfform enctype="multipart/form-data">
<cfinput type="file" name="Artfoto">
<cfinput type="submit" name="vov">
</cfform>
<cfset thisDir = ExpandPath(".")>
<cfif structKeyExists(form,"Artfoto") and len(trim(form.Artfoto))>
<cffile action="upload" fileField="Artfoto" destination="#thisDir#" result="fileUpload" nameconflict="makeunique">
<cfif fileUpload.fileWasSaved>
<cfif IsImageFile("#fileUpload.serverfile#")>
<cfimage action="read" source="#fileUpload.serverfile#" name="test">

</cfif>
</cfif>
</cfif>
<!--- result after submit ---->
<cfdump var="#fileUpload.serverfile#">
<cfdump var="#test#">

So, with ExpandPath(".") all work perfect, but file uploads to Images_tools directory NOT to Images, like I need.
If you replace <cfset thisDir = ExpandPath(".")> by
<cfset thisDir = ExpandPath ("images")> or another equivalent ( /images, \images, ..\images, c:\coldfusion8\wwwroot\mysite\images) , you would see in <cfdump> that variable #fileUpload.serverfile# exists and #test# gives us a error.
I don't understand that!!! However with ExpandPath(".") it works perfect, WHY???!!!
How to write a correct path in ExpandPath brackets?

438
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
LEGEND ,
Oct 23, 2008 Oct 23, 2008
>> <cfset thisDir = ExpandPath("images")>

that should work, if you are in

x/y/z/

and need to get to

x/y/z/images/


You might also try

<cfset thisDir = expandPath('../z/images')>
which would send you up one, then back down and then into the
subfolder... but the first one should work, based on what you posted.


Michael Evangelista, Evangelista Design
Web : www.mredesign.com Blog : www.miuaiga.com
Developer Newsgroups: news://forums.mredesign.com
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
LEGEND ,
Oct 23, 2008 Oct 23, 2008
your #test# throws an error because it is trying to get an image from
the same folder as the calling page, not from /images subfolder.

change your <cfimage> tag to this:
<cfimage action="read" source="images/#fileUpload.serverfile#"
name="test">

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
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
New Here ,
Oct 24, 2008 Oct 24, 2008
LATEST
To Azadi
The problem has been solved.
Grate 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
Resources