|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
problem with cffile action=upload
Hello,
I am creating an e-mail application which allows user to attach upto 3 files. I have a special button called "PREVIEW" in my program. The funstion of the button is to show the body and the source address of the attachments. If any of the attachments is an image it should open the image and dispaly it as attachment while all other files should show the normal source address. I want to do this by uploading the image/* files to server and bring it back to display them. If there is any other way please suggest me. When I tried with my idea...my code looks like below <cfif fileExists("#form.file1#")> Attachment1:<br> <input name="file1" type="hidden" value="#form.file1#"> #form.file1# <cffile action="upload" fileField="form.file1" accept="image/*" nameconflict="makeunique" destination="C:\CFusionMX\wwwroot\address_book\"> <hr><br><br> </cfif> <cfif fileExists("#form.file2#")> Attachment2:<br> <input name="file2" type="hidden" value="#form.file2#"> #form.file2# <cffile action="upload" fileField="form.file2" accept="image/*" nameconflict="makeunique" destination="C:\CFusionMX\wwwroot\address_book\"> <hr><br><br> </cfif> <cfif fileExists("#form.file3#")> Attachment3:<br> <input name="file3" type="hidden" value="#form.file3#"> #form.file3# <cffile action="upload" fileField="form.file3" accept="image/*" nameconflict="makeunique" destination="C:\CFusionMX\wwwroot\address_book\"> </cfif><br><br> The process is uploading the files succesfully but when the file is not an image/* it shows as error...How can I determine which is image file and which is not? If I can know that I can use an if condition and stop other files to be uploaded. Also ,can anyone suggest me how to display files which are located on the server at some known address using HTML. Thanks for your time and consideration. venkatgill |
|
#2
|
|||
|
|||
|
You can use the "accept" attribute of the cffile tag to limit what types of files can be uploaded (based on their file extension). You could also manually inspect the file extensions of your files.
You can get the contents of any directory on the server, images or otherwise, by using cfdirectory.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
I tried to limit the typr of attachement by using
<cffile action="upload" fileField="form.file2" accept="image/*" nameconflict="makeunique" destination="C:\CFusionMX\wwwroot\address_book\"> I want the code to recognize the extension of the file. The user dont know which attachment is image and which is others. So, if any of the attachments is an image it should find it and upload it else it has to disard the upload action. Thanks for your time. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > problem with cffile action=upload |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|