Solved

cffile destination permission error

Posted on 2012-12-31
22
602 Views
Last Modified: 2013-01-04
It appears that cffile does not have permission to write/upload a file to the server.

The following code works when I upload a file from my PC;
<cffile action="upload" destination="#request.ControlPath#documents\original\" mode="777" nameconflict="makeunique" filefield="docFile" accept="application/pdf,application/msword,application/vnd.ms-excel,text/plain,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.ms-powerpoint,application/vnd.ms-powerpoint.presentation.macroEnabled.12">

The following does not work when I upload a file I scanned using Dynamic Web Twain;
<cfoutput>
            <cfset dest = "#request.ControlPath#documents\original\">
            </cfoutput>
            <cffile action="upload" filefield="RemoteFile"  mode="777" destination="#dest#" nameconflict="OVERWRITE" />

But it does work with dest="c:\"
0
Comment
Question by:lantervj
  • 10
  • 10
  • +1
22 Comments
 
LVL 25

Expert Comment

by:dgrafx
ID: 38734642
After scanning with dynamic web twain - where is the file?
Is it on the same machine as your website?

Do you then submit a form sending the twain file to your cffile?
That may be the issue - you need to submit a form when using cffile action=upload.
0
 
LVL 25

Expert Comment

by:dgrafx
ID: 38734648
After reading my answer I see I left off that I was going to say you may want to use cffile action=move - because it is already on the same server so you are not uploading.
If it is not on the same server then you need to use cfftp and not cffile.

good luck
0
 
LVL 15

Expert Comment

by:Gurpreet Singh Randhawa
ID: 38735948
check your path

which is dest,

dump dest and see what you are getting. Afterupload are u checking the file exists with cffile.serverfile try that and see where it is wrong
0
 
LVL 36

Expert Comment

by:SidFishes
ID: 38736912
One other thing to consider - CF needs permission to write to the target folder. If the target folder is anywhere on the network, CF won't have access to it as by default, it runs as local system.

To make a folder accessible in windows (guessing from the word, excel etc..)

1) create a user in AD call it "CFService" give it a stroing pwd that never expires
2) Go to services > CF App Server > Log On Tab and set it to the new user
3) go to target folder and give CFService perms
4) restart CF service

(also fyi mode="777" is only valid for *nix systems)
0
 

Author Comment

by:lantervj
ID: 38739018
I think I'm having trouble with the return from the action page (for one thing).

WebTWAIN.HTTPUploadAllThroughPostASPDF("dev.ttt.com", "/control/documentHandler/actUploadScan.cfm", "Scan_<cfoutput>#users_info.lastname##indivnum#</cfoutput>.pdf");

if (WebTWAIN.ErrorCode != 0)                              //Failed to upload image
                        {
                        alert("error_fromActiveX: "+WebTWAIN.ErrorString+'   error code='+WebTWAIN.ErrorCode);
                        alert(WebTWAIN.HTTPPostResponseString);
                        }
                  else      
                        {                                                                                     //Successful
                        //frmScan.submit();
                        }
 

The WebTWAIN.ErrorString is HTTP Process error and the ErrorCode is 2003.  I have no idea what 2003 means but the ErrorString indicates

1. The write permission is not granted to the specified directory on the web server.

2. The action page is incorrect or returns something from Web server.

3. The Port for uploading is not right.

4. The size of the images you try to upload is beyond the maximum allowed size set on the server.

Since it's not a write permission problem and the port is correct and the size is not the problem, it must be that the action page is returning something. And it does.  It's all html.  I don't know how to stop that.
0
 
LVL 25

Expert Comment

by:dgrafx
ID: 38739859
can you post the file where you have actUploadScan.cfm
there may be something we can see that will solve your error.

But after that's fixed I'm fairly confident that you are not wanting to upload the file as no form is being submitted.
You are actually wanting to simply move the file - or do you even need to move the file?
Once twain is working why not twain it right to it's final destination?

Anyway - post your actUploadScan.cfm code and we'll fix er up for ya!
0
 

Author Comment

by:lantervj
ID: 38740058
actUploadScan.cfm;

<cftry>
            <cfoutput>
            <cfset dest = "#request.ControlPath#documents\original">
            </cfoutput>
            <cffile action="upload" filefield="RemoteFile" destination="#dest#" nameconflict="makeunique" accept="application/pdf,application/msword,application/vnd.ms-excel,text/plain,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.ms-powerpoint,application/vnd.ms-powerpoint.presentation.macroEnabled.12" />

      <cfcatch type="any">
            <cfif left(cfcatch.Message, 34)  eq "The MIME type of the uploaded file">
                  <cfset attributes.message = "The file you uploaded is not a valid format, please try again with a .pdf, .doc, .xls, pptx, or .txt file.">
            <cfelse>
                  <cfset attributes.message = "There was an error with the document file you uploaded<br />Please try again.">
            </cfif>
      </cfcatch>
</cftry>
0
 
LVL 25

Accepted Solution

by:
dgrafx earned 500 total points
ID: 38740103
just comment out your cffile action=upload code and then test to see if file is uploading correctly with the twain widget.
I believe that the twain widget is already uploading the file - isn't it?
Isn't that it's purpose?

if it is not then is there a form.RemoteFile - I don't believe so - is there?

I am ignorant of this widget for one thing - I'll try to research it a bit.
Please post back your findings ...
0
 

Author Comment

by:lantervj
ID: 38740162
Sample code from Dynamic Web Twain:

test_scan.cfm;

<html>
<body>

<SCRIPT  LANGUAGE="javascript">
function btnScan_onclick()
{
      frmScan.DynamicWebTwain1.SelectSource();
      frmScan.DynamicWebTwain1.AcquireImage();
}

function btnUpload_onclick()
{
      var strActionPage;
      var strHostIP;
      
      var CurrentPathName = unescape(location.pathname);      // get current PathName in plain ASCII      
      var CurrentPath = CurrentPathName.substring(0, CurrentPathName.lastIndexOf("/") + 1);
      
      
      strActionPage = CurrentPath+"test_scan_upload.cfm"; //the ActionPage's file path
      strHostIP = "localhost";                   //the host's ip or name

  frmScan.DynamicWebTwain1.HTTPPort = 80;
  frmScan.DynamicWebTwain1.HTTPUploadAllThroughPostASPDF(strHostIP, strActionPage, "tscan2.pdf");

      if (frmScan.DynamicWebTwain1.ErrorCode != 0)                              //Failed to upload image
            {
            alert("error_fromActiveX: "+frmScan.DynamicWebTwain1.ErrorString);
            alert(frmScan.DynamicWebTwain1.HTTPPostResponseString);
            }
      else                                                                                          //Successful
            frmScan.submit();
}


</SCRIPT>

</head>

<body>

<p align="center">
<b>Scan an image</b>
<OBJECT CLASSID = "clsid:5220cb21-c88d-11cf-b347-00aa00a28331">
      <PARAM NAME="LPKPath" VALUE="DynamicWebTwain.lpk">
</OBJECT>  
</p>

<form id="frmScan" action="scrap.cfm" enctype="multipart/form-data" method="post">
      <table width="100%">
      <tr>
      <td>
            
      <center>      
      <object classid="clsid:FFC6F181-A5CF-4EC4-A441-093D7134FBF2" id="DynamicWebTwain1" width="250" height="350"
                  CodeBase = "DynamicWebTWAIN.cab#version=5,0">
               <param name="_cx" value="847">
               <param name="_cy" value="847">
              <param name="JpgQuality" value="80">
              <param name="Manufacturer" value="DynamSoft Corporation">
              <param name="ProductFamily" value="Dynamic Web TWAIN">
              <param name="ProductName" value="Dynamic Web TWAIN">
              <param name="VersionInfo" value="Dynamic Web TWAIN 5.0">
              <param name="TransferMode" value="0">
              <param name="BorderStyle" value="0">
              <param name="FTPUserName" value>
              <param name="FTPPassword" value>
              <param name="FTPPort" value="21">
              <param name="HTTPUserName" value>
              <param name="HTTPPassword" value>
              <param name="HTTPPort" value="80">
              <param name="ProxyServer" value>
              <param name="IfDisableSourceAfterAcquire" value="0">
              <param name="IfShowUI" value="-1">
              <param name="IfModalUI" value="-1">
              <param name="IfTiffMultiPage" value="0">
              <param name="IfThrowException" value="0">
              <param name="MaxImagesInBuffer" value="1">
              <param name="TIFFCompressionType" value="0">
              <param name="IfFitWindow" value="-1">
      </object>
      </center>      
      </td>
      </tr>
            
      <tr>
      <td>
      <center>      
      <input type="button" value="Scan" ID = "btnScan" style="width: 100; height: 30" onclick='return btnScan_onclick()'>
      <input type="button" value="Upload" ID = "btnUpload" style="width: 100; height: 30" onclick='return btnUpload_onclick()'>
      <br>
      </center>
      </td>
      </tr>
</table>
</form>

</body>
</html>



test_scan_upload.cfm;

<cffile action="upload" filefield="RemoteFile" destination="c:\" nameconflict="OVERWRITE" />


scrap.cfm;

<html>

<body>
<!-- Here you can code your results like, so and so doc has been uploaded blah blah blah! -->
</body>
</html>
0
 
LVL 25

Expert Comment

by:dgrafx
ID: 38740527
in your first post you said that if you coded your destination to be "c:\" then everything worked ok - is that correct?
0
 
LVL 25

Expert Comment

by:dgrafx
ID: 38740799
Is "users_info" valid when using webtwain?
Can you hard code something to see if the results vary.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 25

Expert Comment

by:dgrafx
ID: 38740861
0
 

Author Comment

by:lantervj
ID: 38742456
Yes, c:\ works.  Yes, users_info is valid.  I've gone over and over their KB and sample code.
0
 

Author Comment

by:lantervj
ID: 38742464
"#request.ControlPath#documents\original" is being used in both the original upload file function and the new upload scanned image function.  It still works perfectly in the upload file function.
0
 

Author Comment

by:lantervj
ID: 38742490
OK, c:\ works and d:\ works.  Even d:\inetpub\wwwroot\ttt.com\development\control\documents\original works.  But I need the variable to switch from the dev site and the production site. So, I have to come up with the absolute path.  Then I have to stop the post response.
0
 

Author Comment

by:lantervj
ID: 38742511
Main cause of failure was the missing backslash at the end of the path.  Now I just have to stop the response html.
0
 
LVL 25

Expert Comment

by:dgrafx
ID: 38742538
how do you mean "stop the post response"?
0
 

Author Comment

by:lantervj
ID: 38743756
WebTWAIN.HTTPUploadAllThroughPostASPDF("dev.ttt.com", "/control/documentHandler/actUploadScan.cfm?indivnum=<cfoutput>#indivnum#</cfoutput>&docareaid=<cfoutput>#docareaid#</cfoutput>", "Scan_<cfoutput>#indivnum#_#users_info.lastname#</cfoutput>.pdf");
if (WebTWAIN.ErrorCode != 0)                              //Failed to upload image
      {
        alert("error_fromActiveX: "+WebTWAIN.ErrorString+'   error     code='+WebTWAIN.ErrorCode);
      alert(WebTWAIN.HTTPPostResponseString);
      }
      else      
            {                                                                                    //Successful
            //frmScan.submit();
            }

The two alerts for an error always come up because the action page returns a post response.  If it returns a response, WebTWAIN assumes it's an error.  The ResponseString is always html code.  For example, if there was an error (syntax, etc.) I get the html to display the error. Otherwise, I get the html of the page it returns to (which also gets interpreted as an error).

I'm trying to explain as best I can.  The mechanics are above me (I guess).

I'm going back to the WebTWAIN support people again.  It's just that they can't spell Coldfusion.
0
 

Author Comment

by:lantervj
ID: 38743772
The HTTPUploadAllThroughPostASPDF function apparently submits the actUploadScan.cfm page.  It's that response that seems to be the trouble.
0
 
LVL 25

Expert Comment

by:dgrafx
ID: 38743831
ok
I guess i should ask again - isn't the file already on the server without needing to use cffile?
I don't know - just asking.
Try it without and see if the file does indeed get posted to the server.
0
 

Author Comment

by:lantervj
ID: 38744069
The file is being uploaded to the server now.  I'm just getting error messages anyway.  So, I guess this ticket is closed.  I'l post another one for the rest of the problem.
0
 
LVL 25

Expert Comment

by:dgrafx
ID: 38744082
are you saying that the file is posted to server without cffile?
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now