问题描述:

I'm posting a form in ColdFusion on Linux. Form has a file field. CF requires the enctype="multipart/form-data" attribute on the form tag. If I have this, I get a "JRun Servlet Error - 500 No such file or directory"

If I take the attrib out, the form posts and I get the CF "enctype=multipart/form-data" error.

What to do?

Here's a stripped version of the form:

 <form action="post.cfm" name="form2" id="port_form" method="post" enctype="multipart/form-data">

<input type="text" id="name" name="name" value="#port_name#"><br>

<input type="file" id="before" name="before"><br>

<input type="hidden" name="port_id" value="#port_id#" />

<button type="submit" name="post"> Post Portfolio Item </button>

</form>

Here's the page I'm posting to (post.cfm)

 <cfif form.before neq "">

<cfinvoke component = "#application.cfcPath#.file" method = "upload" returnVariable = "beforeFile" theField="before">

<cfelse>

<cfset beforeFile = ''>

</cfif>

<cfif form.after neq "">

<cfinvoke component = "#application.cfcPath#.file" method = "upload" returnVariable = "afterFile" theField="after">

<cfelse>

<cfset afterFile = ''>

</cfif>

<cfinvoke component = "#application.cfcPath#.portfolio" method = "post" beforeFile="#beforeFile#" afterFile="#afterFile#">

<cfif form.port_id eq 0>

<cfset message = "The Portfolio Item has been successfully inserted.">

<cfelse>

<cfset message = "The Portfolio Item has been successfully updated.">

</cfif>

<cf_forward fuseaction="#fusebox.circuit#.home" message="#message#">

网友答案:

Possible reason is that server can not find the uploaded temp file.

Have you tried to make upload without component wrapper?

Simply

<cfif StructKeyExists(Form, "before") AND Form.before NEQ "">
<cffile
    action="upload"
    filefield="before"
    destination="#AbsPathToStoreFile#"
    >
</cfif>

<cfdump var="#cffile#">

If this fails maybe you'll be able to see more details.

网友答案:

You've probably already tried this, but have you tried all upper-case or all lowercase in your paths and file names? Sometimes CF will mangle the upper/lower case thing.

网友答案:

I'm wondering if the temp folder that CF is trying to save the file to is either inaccessible (permissions) or not configured properly.

You should try using the CFFILE tag and specify a folder you have access to.

相关阅读:
Top