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
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
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).
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!
<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>
<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
"#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.
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.
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?
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.