Get directory path pointing to the correct folder?
I'm trying to create link for the file upload. I'm calling file upload function from .cfc
file. The file should be uploaded in a different folder. Here is what I get if after this code is executed in component.cfc
page:
<cfset thisPath = ExpandPath( "./" ) />
C:\wwwroot\myapp\components\
I need to go level back in myapp
and open bug
folder. Then in a bug folder I need to direct the path either to folder1/
documents or folder2/documents
. That will depend on the form field, here is example:
<cfset folder = trim(form.type) EQ 1 "folder1" : "folder2">
The path should either point to:
C:\wwwroot\myapp\bug\folder1\documents\
or
C:\wwwroot\myapp\bug\folder2\documents\
I'm looking for a solution that will work even if I roll this code to a different server with the same directory structure. Is there a good way to achieve this in ColdFusion?
path coldfusion directory coldfusion-10 cffile
add a comment |
I'm trying to create link for the file upload. I'm calling file upload function from .cfc
file. The file should be uploaded in a different folder. Here is what I get if after this code is executed in component.cfc
page:
<cfset thisPath = ExpandPath( "./" ) />
C:\wwwroot\myapp\components\
I need to go level back in myapp
and open bug
folder. Then in a bug folder I need to direct the path either to folder1/
documents or folder2/documents
. That will depend on the form field, here is example:
<cfset folder = trim(form.type) EQ 1 "folder1" : "folder2">
The path should either point to:
C:\wwwroot\myapp\bug\folder1\documents\
or
C:\wwwroot\myapp\bug\folder2\documents\
I'm looking for a solution that will work even if I roll this code to a different server with the same directory structure. Is there a good way to achieve this in ColdFusion?
path coldfusion directory coldfusion-10 cffile
If you know what the path is going to be why not just hard code it? This seems like an application level setting to me and I would just set it as such.
– Miguel-F
Nov 19 '18 at 14:37
Agree with @Miguel-F that this could be considered a config setting for your app. If you don't have a way to set config settings for your app, maybe look at doing that. Also, I keep code separate from data, so uploads never go into code directories. Data directories are mapped to be accessible through the web server, so they can reside anywhere. To do this, you would specify the physical location, and the link location of your data via some sort of config setting.
– Redtopia
Nov 19 '18 at 18:27
Use theonApplicationStart
event to search the webroot of the application and store it either using a mappingthis.mapping["/"] = path
or in a shared variable scope such asapplication
. Here is one approach to look for the root -Application.cfm
can be simply replaced withApplication.cfc
.
– Alex
Nov 19 '18 at 19:32
add a comment |
I'm trying to create link for the file upload. I'm calling file upload function from .cfc
file. The file should be uploaded in a different folder. Here is what I get if after this code is executed in component.cfc
page:
<cfset thisPath = ExpandPath( "./" ) />
C:\wwwroot\myapp\components\
I need to go level back in myapp
and open bug
folder. Then in a bug folder I need to direct the path either to folder1/
documents or folder2/documents
. That will depend on the form field, here is example:
<cfset folder = trim(form.type) EQ 1 "folder1" : "folder2">
The path should either point to:
C:\wwwroot\myapp\bug\folder1\documents\
or
C:\wwwroot\myapp\bug\folder2\documents\
I'm looking for a solution that will work even if I roll this code to a different server with the same directory structure. Is there a good way to achieve this in ColdFusion?
path coldfusion directory coldfusion-10 cffile
I'm trying to create link for the file upload. I'm calling file upload function from .cfc
file. The file should be uploaded in a different folder. Here is what I get if after this code is executed in component.cfc
page:
<cfset thisPath = ExpandPath( "./" ) />
C:\wwwroot\myapp\components\
I need to go level back in myapp
and open bug
folder. Then in a bug folder I need to direct the path either to folder1/
documents or folder2/documents
. That will depend on the form field, here is example:
<cfset folder = trim(form.type) EQ 1 "folder1" : "folder2">
The path should either point to:
C:\wwwroot\myapp\bug\folder1\documents\
or
C:\wwwroot\myapp\bug\folder2\documents\
I'm looking for a solution that will work even if I roll this code to a different server with the same directory structure. Is there a good way to achieve this in ColdFusion?
path coldfusion directory coldfusion-10 cffile
path coldfusion directory coldfusion-10 cffile
asked Nov 19 '18 at 13:37
espresso_coffee
1,98142043
1,98142043
If you know what the path is going to be why not just hard code it? This seems like an application level setting to me and I would just set it as such.
– Miguel-F
Nov 19 '18 at 14:37
Agree with @Miguel-F that this could be considered a config setting for your app. If you don't have a way to set config settings for your app, maybe look at doing that. Also, I keep code separate from data, so uploads never go into code directories. Data directories are mapped to be accessible through the web server, so they can reside anywhere. To do this, you would specify the physical location, and the link location of your data via some sort of config setting.
– Redtopia
Nov 19 '18 at 18:27
Use theonApplicationStart
event to search the webroot of the application and store it either using a mappingthis.mapping["/"] = path
or in a shared variable scope such asapplication
. Here is one approach to look for the root -Application.cfm
can be simply replaced withApplication.cfc
.
– Alex
Nov 19 '18 at 19:32
add a comment |
If you know what the path is going to be why not just hard code it? This seems like an application level setting to me and I would just set it as such.
– Miguel-F
Nov 19 '18 at 14:37
Agree with @Miguel-F that this could be considered a config setting for your app. If you don't have a way to set config settings for your app, maybe look at doing that. Also, I keep code separate from data, so uploads never go into code directories. Data directories are mapped to be accessible through the web server, so they can reside anywhere. To do this, you would specify the physical location, and the link location of your data via some sort of config setting.
– Redtopia
Nov 19 '18 at 18:27
Use theonApplicationStart
event to search the webroot of the application and store it either using a mappingthis.mapping["/"] = path
or in a shared variable scope such asapplication
. Here is one approach to look for the root -Application.cfm
can be simply replaced withApplication.cfc
.
– Alex
Nov 19 '18 at 19:32
If you know what the path is going to be why not just hard code it? This seems like an application level setting to me and I would just set it as such.
– Miguel-F
Nov 19 '18 at 14:37
If you know what the path is going to be why not just hard code it? This seems like an application level setting to me and I would just set it as such.
– Miguel-F
Nov 19 '18 at 14:37
Agree with @Miguel-F that this could be considered a config setting for your app. If you don't have a way to set config settings for your app, maybe look at doing that. Also, I keep code separate from data, so uploads never go into code directories. Data directories are mapped to be accessible through the web server, so they can reside anywhere. To do this, you would specify the physical location, and the link location of your data via some sort of config setting.
– Redtopia
Nov 19 '18 at 18:27
Agree with @Miguel-F that this could be considered a config setting for your app. If you don't have a way to set config settings for your app, maybe look at doing that. Also, I keep code separate from data, so uploads never go into code directories. Data directories are mapped to be accessible through the web server, so they can reside anywhere. To do this, you would specify the physical location, and the link location of your data via some sort of config setting.
– Redtopia
Nov 19 '18 at 18:27
Use the
onApplicationStart
event to search the webroot of the application and store it either using a mapping this.mapping["/"] = path
or in a shared variable scope such as application
. Here is one approach to look for the root - Application.cfm
can be simply replaced with Application.cfc
.– Alex
Nov 19 '18 at 19:32
Use the
onApplicationStart
event to search the webroot of the application and store it either using a mapping this.mapping["/"] = path
or in a shared variable scope such as application
. Here is one approach to look for the root - Application.cfm
can be simply replaced with Application.cfc
.– Alex
Nov 19 '18 at 19:32
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53375852%2fget-directory-path-pointing-to-the-correct-folder%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53375852%2fget-directory-path-pointing-to-the-correct-folder%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
If you know what the path is going to be why not just hard code it? This seems like an application level setting to me and I would just set it as such.
– Miguel-F
Nov 19 '18 at 14:37
Agree with @Miguel-F that this could be considered a config setting for your app. If you don't have a way to set config settings for your app, maybe look at doing that. Also, I keep code separate from data, so uploads never go into code directories. Data directories are mapped to be accessible through the web server, so they can reside anywhere. To do this, you would specify the physical location, and the link location of your data via some sort of config setting.
– Redtopia
Nov 19 '18 at 18:27
Use the
onApplicationStart
event to search the webroot of the application and store it either using a mappingthis.mapping["/"] = path
or in a shared variable scope such asapplication
. Here is one approach to look for the root -Application.cfm
can be simply replaced withApplication.cfc
.– Alex
Nov 19 '18 at 19:32