Alter the Name of a File Being Uploaded Cffile

File Upload with cfform
At last! File upload was, in my stance, one of the most important missing features for Flash RIAs to be taken seriously. One of the reasons we couldn't reproduce HTML forms with Flash CFForm was the file upload. Only now that the new Flash Player has file I/O features, we can use it to incorporate them to Wink forms, and make information technology fifty-fifty better than regular file upload, with more than user feedback such as progress bars. As y'all may expect, you need the Flash Thespian 8 to run this example. In the nothing file yous will find a custom tag, an case, and a swf file.

We have implemented most of the I/O methods provided by the new API, and use them to add together a progress bar and some progress information such as percent and total bytes uploaded.

The custom tag consists of 2 tags, an enclosing cf_flashUpload, and an inner tag, cf_flashUploadInput.

This is the simplest example on how to use the custom tag, with default values:

<cf_flashUpload name="defaultInput" actionFile="upload.cfm">
<cf_flashUploadInput />
</cf_flashUpload>

A more complex instance would be:

<cf_flashUpload label="Movie" proper name="myFile2" fileTypes="*.jpg;*.png;*.gif" fileDescription="Image files" actionFile="upload.cfm">
<cf_flashUploadInput buttonStyle="corner-radius: 0;" inputStyle="fontWeight:bold" inputWidth="eighty" uploadButton="true" uploadButtonLabel="Upload Label" chooseButtonLabel="Choose file" progressBar="truthful" progressInfo="truthful" />
</cf_flashUpload>

flashUpload Usage:
Attributes:

  • name: Required; Name of the text input that volition incorporate the proper name of the file to upload
  • actionFile: Required; File that will handle the upload. Information technology can include query string variables to identify this file. Example: upload.cfm?id=xv
  • label: Label to put next to the control.
  • fileTypes: extensions to have, separated by semicolons. Example: *.jpg;*.png;*.gif
  • fileDescription: Text to describe accepted files
  • maxSize: maximum file size in Kb to upload. Defaults to no limit
  • swf: proper noun of the swf file that contains the i/o libraries. Only needed if your swf is not in the same dir as your cfform

flashUploadInput Usage:
Attributes:

  • inputWidth: with of the text input where file name is shown
  • buttonStyle: manner applied to choose and upload buttons
  • uploadButton: true/false, default truthful. Adds an upload push. If you set it fake, you must put the generated variable chosen "theNameOfYourInput_uploadScript" in some other button ("theNameOfYourInput" is the name assigned in the flashUpload tag name attribute)
  • progressBar: truthful/false default true. Adds a progress bar.
  • progressInfo: true/faux default true. Adds an output area to show progress info
  • progressBarStyle: style of progress bar
  • uploadButtonLabel: label of "Upload" button
  • chooseButtonLabel: characterization of "File browse" push button

Notes on error codes:

404: As you may know, 404 ways "file not found". As such, it ways that the address you are sending the upload to does not be or it cannot exist establish by the web server. You will demand to make sure you are pointing the "actionFile" aspect to the right identify. When in uncertainty, try using an absolute path (ie: /myuploads/directory/upload.cfm)

500: This error could be due to many things, but it is an "Internal server fault". Issues to bank check:
- You are uploading files larger than the allowed post size set in the CF administrator. Meet the setting "Maximum size of mail data" in the Settings page of the CF administrator. The default I think is 100MB
- You are uploading large files and CF is running out of memory. CF has to put the whole size in retention while it gets uploaded before information technology saves it to disk. If you have access to the logs (the coffee output logs, non the regular cf logs), check for this error.

A couple of notes from the comments:

Posting additional data: handling a file upload posted by Flash is dissimilar than handling an upload posted past an html form. The showtime difference is that y'all cannot specify the name of the file input, it will e'er be "FileData". The second difference is that when y'all trigger the file upload, yous are only sending the file contents and the file proper name, but cannot transport anything else, whether information technology was in the grade you have or non. That is, on your "form" scope in upload.cfm, yous will simply see those two fields. The only data yous tin ship is what you suspend to the upload action file name query string (ie: upload.cfm?variable1=test), and you will get that in the URL scope of upload.cfm.

Getting data dorsum from the upload action page: The only things y'all will get from the upload activeness page are HTTP condition codes. 200 will mean the upload was successful (or that at least there was no server error). If you change the file name, make a query to retrieve anything (ie: an id), you will not exist able to transport that back to the calling page. You can do any of that, for example if yous wanted to send an electronic mail after a file was uploaded, or resize the paradigm you uploaded, as this is a normal cfm page, but you cannot communicate any of this to the calling page.
An update on this: If your user is running player 9.0.28, you could become information dorsum from the upload action page. Y'all will have to, however, modify the .fla that implements the uploading. Meet the docs.

View alive example (delight exist gentle with our bandwidth)
Download the source

kramerclon1975.blogspot.com

Source: https://www.asfusion.com/blog/entry/file-upload-with-coldfusion-flash-forms

0 Response to "Alter the Name of a File Being Uploaded Cffile"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel