• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 625
  • Last Modified:

cffile destination permission error

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
lantervj
Asked:
lantervj
  • 10
  • 10
  • +1
1 Solution
 
dgrafxCommented:
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
 
dgrafxCommented:
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
 
Gurpreet Singh RandhawaWeb DeveloperCommented:
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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
SidFishesCommented:
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
 
lantervjAuthor Commented:
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
 
dgrafxCommented:
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
 
lantervjAuthor Commented:
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
 
dgrafxCommented:
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
 
lantervjAuthor Commented:
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
 
dgrafxCommented:
in your first post you said that if you coded your destination to be "c:\" then everything worked ok - is that correct?
0
 
dgrafxCommented:
Is "users_info" valid when using webtwain?
Can you hard code something to see if the results vary.
0
 
lantervjAuthor Commented:
Yes, c:\ works.  Yes, users_info is valid.  I've gone over and over their KB and sample code.
0
 
lantervjAuthor Commented:
"#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
 
lantervjAuthor Commented:
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
 
lantervjAuthor Commented:
Main cause of failure was the missing backslash at the end of the path.  Now I just have to stop the response html.
0
 
dgrafxCommented:
how do you mean "stop the post response"?
0
 
lantervjAuthor Commented:
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
 
lantervjAuthor Commented:
The HTTPUploadAllThroughPostASPDF function apparently submits the actUploadScan.cfm page.  It's that response that seems to be the trouble.
0
 
dgrafxCommented:
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
 
lantervjAuthor Commented:
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
 
dgrafxCommented:
are you saying that the file is posted to server without cffile?
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 10
  • 10
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now