This content has been marked as final. Show 8 replies
Okay I found the function GetHTTPRequestData(), but the uploaded filename is not in the POST header. Neither is it in the form data from CF (though it is in the form data from Flex) and yet from the CF form, the correct filename is saved on the server. How does CF know the name of the uploaded file on the server?
> I am trying to upload a picture file using cffile. It works fine from a cf
> input form, but when I try to do the same thing from Flex, I get an HTTP
I can't find any clues at the link you have given.
I can see from the data received at the cffile upload script that the data from Flex is correct and the same as the data received from CF except that the form has two additional fields, but these are not relevant as I have tried deleting them with StructDelete and there is no difference.
The code in cffile upload is just:
<cffile action="upload" filefield="photo" accept="image/jpeg, image/gif" destination="D:inetpub\mysite\images" nameconflict="overwrite">
I think the problem must be with the destination which is why I get an HTTPStatus Internal Server Error with upload from Flex. With the CF input page, the file is saved correctly with the code as shown.
From Flex, if I make other changes, I get different errors, but it doesn't matter what nonsense I put in destination, I always get this same HTTPStatus error.
The destination is a shared server and images folder has read and write privileges for all users.
I just can't work out what can be wrong.
I have set up a test on my localhost and I get the same Flex error.
Also I get an error from the CF test file.
Test file is:
<form action="imageupload.cfm" enctype="multipart/form-data" method="post">
<input type="file" name="photo" size="50">
<input type="submit" value="Upload">
<cffile action="upload" filefield="photo" accept="image/jpeg, image/gif" destination="C:CFusionMX7\wwwroot\images" nameconflict="overwrite">
I get the error:
The destination "C:CFusionMX7\wwwroot\images" specified in the CFFILE tag is invalid.
The destination either does not exist or is not accessible by this tag.
What is wrong?? The destination certainly exists, so why is it not accessible? The folder has read/write privilege for everyone.
> I can't find any clues at the link you have given.
these were examples as to "how to do it". on the flex end, what are you using to
handle the uploads? that link will show you how it's done.
> The destination "C:CFusionMX7\wwwroot\images" specified in the CFFILE tag is
> The destination either does not exist or is not accessible by this tag.
why not believe the error message?
> What is wrong?? The destination certainly exists, so why is it not accessible?
maybe it's really C:\CFusionMX7\wwwroot\images
Thanks so much for that, I've looked at this code for so long and changed it so many times I can't see what's right or wrong any more.
I think I've finally found the cause of the real problem - why CF won't save the Flex upload - at http://www.adobe.com/devnet/coldfusion/articles/multifile_upload_03.html
It seems that the accept type can only be application/octet-stream with a Flex upload and you have to validate the file type afterwards.
Hope this is the solution and thanks for your help.
Yes this finally is the code that works for Flex uploads.
<cfset acceptedFileExtensions = "jpg,jpeg,gif">
<cffile action="upload" filefield="photo" accept="application/octet-stream" destination="D:\inetpub\mysite\images" nameconflict="overwrite">
<cfset filecheck = listFindNoCase(acceptedFileExtensions, File.ServerFileExt)>
<cfif filecheck EQ false>
<cffile action="delete" file="D:\inetpub\mysite\images\#File.ServerFile#">