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

Error uploading a file

Participant ,
Mar 01, 2016 Mar 01, 2016

Copy link to clipboard

Copied

I inherited an application a few years ago and up until today, a particular part of the code has worked flawlessly.   It was supposed to upload a pdf file and attach it to a record in the database.  Now, I receive a generic message and I have no clue what is wrong.  I mostly am an Oracle DBA and can do enough CF to get by, until now.   What can I add to this to help give me an idea of what is wrong?  Thanx.  In the below code piece, the cflocation line just goes on, but I can't do that here.

<cftry>

   <cffile action = "upload"  

             fileField = "requiredFILENAME"  

             destination = #newDest#     

             accept = "application/pdf">

<cfcatch>

   <CFLOCATION url="upload378.cfm?F378_ID=#FORM.F378_ID#&ERROR=We were unable to upload your file. Please try again..&FMBIC_DT=#FORM.FMBIC_DT#&IE_PMO_DT=#FORM.IE_PMO_DT#

                                 &IE_PMOMILCON_DT=#form.IE_PMOMILCON_DT#">

</cfcatch>

</cftry>


Views

10.1K

Translate

Translate

Report

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 Expert , Aug 01, 2016 Aug 01, 2016

I have reviewed this thread. It is now clear to me why Coldfusion is unable to find the destination directory.

When you began the thread, the value of the destination directory (newDest) was

\\TestServer\secure\Authorization\378Docs\

and the action page for the upload form was

\\TestServer\secure\Authorization\upload378Act.cfm

Destination directory and upload form appeared to have the same root directory, namely, \\TestServer\secure\Authorization\. However, in the most recent error-message, the value

...

Votes

Translate

Translate
Advocate ,
May 17, 2016 May 17, 2016

Copy link to clipboard

Copied

It's time to get your network administrator involved. And the server administrator if they are not the same person.

If ColdFusion cannot access a file, that you know to exist, then the user account that the ColdFusion service is using, doesn't have the necessary security privileges to access that folder. Only your administrator(s) can sort out security problems.

Cheers

Eddie

Votes

Translate

Translate

Report

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
Participant ,
May 18, 2016 May 18, 2016

Copy link to clipboard

Copied

I've had the SysAdmin involved and he ensures me (with screen shots) that everything is correct and that it is my problem.  I had another error with this app, earlier, where it was trying to produce a report (an Excel spreadsheet) and it threw the error message, "access denied".  I was able to go to the directory in FTP and change the permissions to 777 and it worked.  I will attempt that with this, but I don't see how it would change the not found issue. 

Votes

Translate

Translate

Report

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
Advocate ,
May 18, 2016 May 18, 2016

Copy link to clipboard

Copied

It occurs to me that you said it is a UNC path, but you aren't showing the initial double-backslash in your posts. You are using one in your code, right?

For example: \\MachineName\folder\subfolder\file.ext

Cheers

Eddie

Votes

Translate

Translate

Report

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
Participant ,
May 19, 2016 May 19, 2016

Copy link to clipboard

Copied

Ok, it's highly likely I misunderstood UNC...

The directory is assigned in Application.cfc

<cfset authfileroot="\xxxxxxxx\secure\Authorization\">

In the .cfm I am working with, the storage location of the uploaded file is assigned as such:

<CFOUTPUT>

   <CFSET newDest = #authfileroot#&"378Docs\"/>

</CFOUTPUT>

I hope that answers your question.

Votes

Translate

Translate

Report

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
Advocate ,
May 19, 2016 May 19, 2016

Copy link to clipboard

Copied

Yes, that makes more sense.

You are not specifying which drive the folder is on.

Is it a local hard drive on the server or is it a network share?

If it is a local hard drive, then add the drive letter (like C: or D:) however, if it is a network share, then use a UNC path, which your SysAdmin can give you.

Cheers

Eddie

Votes

Translate

Translate

Report

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
Participant ,
May 19, 2016 May 19, 2016

Copy link to clipboard

Copied

I believe it's a local drive.  It's the same drive that contains the CF code.  When you select the option to upload the file, you are in the same directory where the code for that option resides.  There is a subdirectory that is defined (as mentioned earlier) where the physical uploaded file resides and a link to that file is stored in the database.

The biggest issue I have is, 1) it worked flawlessly up until a little while ago (beginning of this thread)  2) the gov't sysadmin says that nothing has been done to change directories or permissions  3) there are no references to drive letters in any part of the code.  The way I get it in my simple mind is, when you log in, you are virtually logging in as the schema/user for the database and all the files and database are yours to update as the application allows.  What would have caused this to suddenly change after working fine for a while?  Newer version of Windows?  CF?  Supposedly my development server, the Test server, and the Production server are all running the same version of Windows, CF, and Oracle.   The original code was written with CF 8 and I believe we're at 11 now.  I found a few things that caused me issues between the old and new versions of CF (i.e.- getbuiltin scopes), but nothing like this.

Votes

Translate

Translate

Report

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
Advocate ,
May 19, 2016 May 19, 2016

Copy link to clipboard

Copied

If you don't provide an explicit path, ColdFusion will rely on the Windows process' "current directory" when using the <cffile> tag, which differs from tags like <cfinclude> where CF uses the current script's folder as the "current directory."

The current directory of a Windows process is complicated and fragile. It's best to be explicit by using a full path including the drive, even if it doesn't fix your current problem.

I can't answer your questions as to why your script no longer works, but using an explicit path will rule out the unexpected results of the current directory not being what you expect it to be.

Cheers

Eddie

Votes

Translate

Translate

Report

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
Participant ,
Jun 24, 2016 Jun 24, 2016

Copy link to clipboard

Copied

The only explicit path in all the code is

\\servername\test\sites\codebase  directory structure

The Gov't SysAdmins are running 50 or so applications/databases on a VMWare Server.  They have said they can't (won't) give me a more explicit path.  So I guess I am screwed.   The biggest issue I have at present is why it couldn't upload the file.  Just the generic message: We were unable to upload your file. Please try again..

I have CF Admin debugging on and don't see anything significant.   Trying again just gives the same error.  At first I thought it was due to special characters in the filename and changed the file name to eliminate special characters and embedded blanks.  No change.  Really baffled.

Votes

Translate

Translate

Report

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 ,
Jun 24, 2016 Jun 24, 2016

Copy link to clipboard

Copied

CFTRY/CFCATCH/CFDUMP will at least alert you to the issue, with specifics.  I just now noticed in your first post that there already is a CFTRY/CFCATCH, but all it is doing is redirecting to another page with a lot of URL parameters, one of which is the error message text.  If you were to put a CFMAIL (type="html") with a CFDUMP of the #cfcatch# variable, you should see what is triggering the error.

As far as I know, you cannot use "\\servername\path\to\upload\" for cffile uploads.  If you use a relative path (ie, "/path/to/folder/") then CF will use that in relation to the CF temp folder, which resides within CFIDE, I think.  You must use something like "F:/path/to/folder/".  Unless you're in a unix/linux environment.  (NOTE:  If you can use a URL as a location, you'll have to use CFFTP to FTP the file - CFFILE does not work across servers.)

If the sysadmins will not assign a full physical drive path, then tell them that the only alternative is to store the files in the database.  The upside to this is that if you ever have to delete one, you just delete it in the database, as opposed to deleting the reference from the database AND using cffile action="delete" to remove the binary, itself.  The downsides are A) depending upon the file sizes, you could bloat the database; and B) if the site/app has over a certain number of users, this will bottleneck your network.  (Third edit: If space on the webserver is an issue, there's always SAN storage.)

HTH,

^_^

Votes

Translate

Translate

Report

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
Advocate ,
Jun 27, 2016 Jun 27, 2016

Copy link to clipboard

Copied

That "generic" message is coming from the code that you quoted in your very first post here. It is not a ColdFusion message. We asked you to temporarily remove that line of code because it is masking the ColdFusion message.

Please do so and then let us know what message ColdFusion is giving you.

Cheers

Eddie

Votes

Translate

Translate

Report

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
Participant ,
Jun 27, 2016 Jun 27, 2016

Copy link to clipboard

Copied

With all the things that are wrong with this mess I inherited, I skipped over your comment.  My apologies.

I did as you suggested and ended up having to completely delete the error message because, even commented out it still gave me the message.  I copied the file and made changes to the new one.  Loaded it up to the directory and got this message:

The value of the attribute destination, which is currently \TestServer\secure\Authorization\378Docs\, is invalid.

I checked the directories in the FTP tool I use to upload and the directory is there and it is spelled correctly.   No clue what to do with this.

Votes

Translate

Translate

Report

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 Expert ,
Jun 27, 2016 Jun 27, 2016

Copy link to clipboard

Copied

This is going on a bit. Is it still about uploading a file?

Votes

Translate

Translate

Report

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
Participant ,
Jun 27, 2016 Jun 27, 2016

Copy link to clipboard

Copied

Yes.  There are numerous problems with this code, but this particular thing is about uploading a .pdf file and associating it with a record in the database.  All the files are stored in the location listed in the code.   It has worked for years and all of a sudden stopped.   The customer pulled me off on another priority, and now this is top priority.   So glad when this contract is over in September.

Votes

Translate

Translate

Report

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
Advocate ,
Jun 27, 2016 Jun 27, 2016

Copy link to clipboard

Copied

I understand your frustration. Let's take a closer look at the path you mention: "\TestServer\secure\Authorization\378Docs"

If "TestServer" is a folder on a drive on the server itself, then you need to provide the drive letter, for example: "d:\TestServer\secure\Authorization\378Docs"

If, however, "TestServer" is the name of a server, then you need to start the path with two slashes: "\\TestServer\secure\Authorization\378Docs"

Cheers

Eddie

Votes

Translate

Translate

Report

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
Participant ,
Jun 27, 2016 Jun 27, 2016

Copy link to clipboard

Copied

TestServer is the server name.  I have changed it so the actual name isn't displayed.  My customer gets upset when I post actuals.

Votes

Translate

Translate

Report

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
Advocate ,
Jun 27, 2016 Jun 27, 2016

Copy link to clipboard

Copied

That's okay. What is important is that the value you use in the actual environment starts with two slashes.

Cheers

Eddie

Votes

Translate

Translate

Report

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
Participant ,
Jun 27, 2016 Jun 27, 2016

Copy link to clipboard

Copied

Same exact error with the extra leading \

Votes

Translate

Translate

Report

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
Advocate ,
Jun 27, 2016 Jun 27, 2016

Copy link to clipboard

Copied

If security privileges are wrong then there is nothing you can do to make this work.

If you look back at the test I had you do on May 17th in this thread, it is proof positive that the ColdFusion server doesn't have access to a file that you know to exist. You can show this to the sys admin to demonstrate that you are doing your part correctly. If you have the full path and file name correct then there is nothing more you can do. The ball is in the sys admin's court.

Cheers

Eddie

Votes

Translate

Translate

Report

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
Advocate ,
Jun 27, 2016 Jun 27, 2016

Copy link to clipboard

Copied

Okay. Let's check that the server can accept files correctly first before troubleshooting the desired destination.

Create a folder on the server's C: drive called TestTmp.

Change the cffile tag to the following:

<cffile action = "upload"

  fileField = "requiredFILENAME"

  destination = "c:\TestTmp">

Now test the upload and see if the file appears in the new folder.

Cheers

Eddie

Votes

Translate

Translate

Report

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
Participant ,
Jun 27, 2016 Jun 27, 2016

Copy link to clipboard

Copied

I don't have access to the C drive.   I have access to the directories that I use WS_FTP to load files up to.   That's all the gov't SysAdmin allows me to access.  The directory structure in the code exists and the permissions are for full control.  Not sure where to go with this.

Votes

Translate

Translate

Report

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
Advocate ,
Jun 27, 2016 Jun 27, 2016

Copy link to clipboard

Copied

You cannot use cffile to upload directly to an FTP site. You have to accept the file locally on the server first and then use cfftp to transfer the files to the FTP site.

Cheers

Eddie

Votes

Translate

Translate

Report

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
Participant ,
Jun 27, 2016 Jun 27, 2016

Copy link to clipboard

Copied

Understood, but I only have access to the FTP site.   I am under the impression that the FTP site mirrors to the actual Test server, but I cannot get the gov't SysAdmin to verify that.  Every other upload in the application works like this, and they all work fine.  This error just popped up on the Production machine when this thread started, and I have been trying to solve it, on and off, since.

Votes

Translate

Translate

Report

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 ,
Jun 27, 2016 Jun 27, 2016

Copy link to clipboard

Copied

\Testserver\secure\Authorization\378Docs\ is an invalid path for CFFILE.  If it has to go from one server to another, you need to use CFFTP because CFFILE only works on the server it is run from.

^_^

Votes

Translate

Translate

Report

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
Advocate ,
Jun 27, 2016 Jun 27, 2016

Copy link to clipboard

Copied

That's what I said, however I'm betting FTP is a red herring. What Louie seems to be saying is that he only has FTP access to that folder from his workstation. The server is supposed to be able to access the UNC path directly.

Cheers

Eddie

Votes

Translate

Translate

Report

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 ,
Jun 27, 2016 Jun 27, 2016

Copy link to clipboard

Copied

Sorry.. at the time I responded, there were only 47 messages as opposed to the 51 that there are, now. 

^_^

Votes

Translate

Translate

Report

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
Documentation