Avatar of lantervj
lantervj
Flag for United States of America asked on

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:\"
ColdFusion Language

Avatar of undefined
Last Comment
dgrafx

8/22/2022 - Mon
dgrafx

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.
dgrafx

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
Coast Line

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
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
SidFishes

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)
lantervj

ASKER
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.
dgrafx

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!
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
lantervj

ASKER
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>
ASKER CERTIFIED SOLUTION
dgrafx

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
lantervj

ASKER
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>
dgrafx

in your first post you said that if you coded your destination to be "c:\" then everything worked ok - is that correct?
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
dgrafx

Is "users_info" valid when using webtwain?
Can you hard code something to see if the results vary.
dgrafx

lantervj

ASKER
Yes, c:\ works.  Yes, users_info is valid.  I've gone over and over their KB and sample code.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
lantervj

ASKER
"#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.
lantervj

ASKER
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.
lantervj

ASKER
Main cause of failure was the missing backslash at the end of the path.  Now I just have to stop the response html.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
dgrafx

how do you mean "stop the post response"?
lantervj

ASKER
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.
lantervj

ASKER
The HTTPUploadAllThroughPostASPDF function apparently submits the actUploadScan.cfm page.  It's that response that seems to be the trouble.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
dgrafx

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.
lantervj

ASKER
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.
dgrafx

are you saying that the file is posted to server without cffile?
Your help has saved me hundreds of hours of internet surfing.
fblack61