Ok this may be a rough workaround but this allows you to use multiple <input type="file" name="aFile" > boxes in a form and not only upload them but write their filenames to a database.
First the Easy part: your form should look something like this
A quick break down of this code: First I check to see if file im passing is there or not. This is important because your app will crash if the CFFILE trys to upload a file that isnt there.
The the CFFILE then begins to do its work, Action, being what you want it to do with the File, filefield being the file variable its working with (in this case the name of the input tag from the calling page.) Destination being the directory to store the file in. Accept is very important if you want to limit the files the enduser can upload, My app allows the user to upload graphics to database for viewing in a screenshot gallery.
ACCEPT="image/jpg, image/pjpeg,image/gif,image/bmp,image/tiff" Make sure you put a comma between each mime type in your accept list
Lastly, Nameconflict tells the server what to do if duplicate filenames exist, OVERWRITE just replaces the file, MAKEUNIQUE gives the new uploaded file a new random name. SKIP doesnt upload the file.
The main problem we have now isthat the FILE.SERVERFILE is rewritten after every CFFILE tag, so if you want to store the file name in a database you can only store the filename of the last file uploaded. To get around this we store the FILE.SERVERFILE value in a variable after each CFFILE tag. Now if you need to store the filename you just store the variables you created instead of storing FILE.SERVERFILE directly.
I hope this helps people having problems with this, if you have any questions feel free to contact me at glen@headcasemods.com
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.