How To The Use `<cffile action = “upload”>` Function In ColdFusion?
Description:-
After a file is uploaded, you can get status information using file upload parameters. To refer to parameters, you need to specify an alternate name in the result attribute, the name you specified there.
The following file upload status parameters are available after an upload:-
Parameter | Description |
attemptedServerFile | The initial name ColdFusion is used when attempting to save a file. |
clientDirectory | Directory location of the file uploaded from the client’s system. |
clientFile | Name of the file uploaded from the client’s system. |
clientFileExt | Extension of the uploaded file on the client system (without a period). |
clientFileName | Name of the uploaded file on the client system (without an extension). |
contentSubType | MIME content subtype of the saved file. |
contentType | MIME content type of the saved file. |
dateLastAccessed | Date and time the uploaded file was last accessed. |
fileExisted | Whether the file existed with the same path (yes or no). |
fileSize | Size of the uploaded file in bytes. |
fileWasAppended | Whether ColdFusion appended an uploaded file to a file (yes or no). |
fileWasOverwritten | Whether ColdFusion overwrote a file (yes or no). |
fileWasRenamed | Whether the uploaded file was renamed to avoid a name conflict (yes or no). |
fileWasSaved | Whether ColdFusion saves a file (yes or no). |
oldFileSize | Size of a file that was overwritten in the file upload operation. |
serverDirectory | The directory of the file is saved on the server. |
serverFile | The filename of the file is saved on the server. |
serverFileExt | Extension of the uploaded file on the server (without a period). |
serverFileName | Name of the uploaded file on the server (without an extension). |
timeCreated | Time the uploaded file was created. |
timeLastModified | Date and time of the last modification to the uploaded file. |
Note:-
File status parameters are read-only. They are set to the results of the most recent cffile
operation. If two cffile
tags execute, the results of the second overwrite the first one unless you have specified a different result variable in the result attribute.
conclusion:-
If you upload a file with zero bytes, there is no exception. Instead, the file gets uploaded to the server. By default, uploading an empty file will not produce an error. You can, however, disallow this by changing the property, coldfusion.file.upload.disallowemptyfileupload
, to true
.