One more time...
Here's some code that may help... use it if you'd like:
CLIENT SIDE JS
<cfset accepttypes =" '.jpg','.gif'"> <!--- one or more acceptable file
extentions separated by commas in single quotes--->
<cfoutput>
<script>
extArray = new Array(#accepttypes#);
function LimitAttach(form, file) {
allowSubmit = false;
if (!file) return;
while (file.indexOf("\\") != -1)
file = file.slice(file.indexOf("\\") + 1);
ext = file.slice(file.indexOf(".")).toLowerCase();
for (var i = 0; i < extArray.length; i++) {
if (extArray[i] == ext) { allowSubmit = true; break; }
}
if (allowSubmit) {
form.submit();
document.body.style.cursor="wait";
}
else
alert("Please only upload files that end in types: "
+ (extArray.join(" ")) + "\nPlease select the "
+ "correct file type.");
}
</script>
<cfoutput>
<form action="img_upload2.cfm" enctype="multipart/form-data"
method="post" >
Select the image file to upload: <input type="file"
name="file" size="60">
<input type="button" name="Upload" value="Upload"
onclick="LimitAttach(this.form, this.form.file.value);">
</form>
SERVER SIDE:
<cftry>
<cffile action="upload" filefield="file" destination="your_path"
nameconflict="makeunique" accept = "MIME type "> (for Mime types, see
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_f_10.html)
<cfcatch>Output error message the mime type was not
accepted<cfabort></cfcatch></cftry>
<cfset filetype=ListLast(serverfile,".")>
<cfif filetype is "jpg" or filetype is "gif" > <!--- list your types
here --->
Accept the file and do action
<cfelse>
Reject file for wrong extension, output error message, delete
it, abort
</cfif>
I think this should cover you. Hope this helps.
Robert
Robert Harrison
Director of Interactive Services
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:355963
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm