jasch2244
asked on
Cffile example please?
My question is two part so I can get a better understanding of using cffile and how to impliment into my project. I'm trying to create a transaction center for a real estate application where the user can upload files to share with others (mortgage people, title / closing companies other agents etc.). I'm having a problem understanding how this will work using cffile (upload).
Question one: If the folder does not exsist on the server is there a way to create one via a form and coldfusion?
Question two: Do you have an example of how to use cffile to upload multiple documents at one time and store the name into the database?
Question one: If the folder does not exsist on the server is there a way to create one via a form and coldfusion?
Question two: Do you have an example of how to use cffile to upload multiple documents at one time and store the name into the database?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
adobe cf livedocs has all the examples you may need:
<cffile>: http://livedocs.adobe.com/coldfusion/8/Tags_f_02.html
<cffile action="upload">: http://livedocs.adobe.com/coldfusion/8/Tags_f_10.html
PS: you can download CFML Reference Manual and CF Dev Guide free PDFs from adobe.com if you do not have them: http://www.adobe.com/support/documentation/en/coldfusion/
as for your questions:
>> is there a way to create [a folder] via a form and coldfusion?
yes, there is. check out <cfdirectory action="create"> tag:
<cfdirectory>: http://livedocs.adobe.com/coldfusion/8/Tags_d-e_03.html
using <cfdirectory>: http://livedocs.adobe.com/coldfusion/8/manageFiles_7.html
>> example of how to use cffile to upload multiple documents at one time and store the name into the database?
read these:
http://www.bennadel.com/blog/1117-Ask-Ben-Uploading-Multiple-Files-Using-ColdFusion.htm
http://www.devarticles.com/c/a/ColdFusion/Multiple-File-Upload-with-CFFILE/
https://www.experts-exchange.com/questions/23730630/coldfusion-multiple-file-upload.html
Azadi
<cffile>: http://livedocs.adobe.com/coldfusion/8/Tags_f_02.html
<cffile action="upload">: http://livedocs.adobe.com/coldfusion/8/Tags_f_10.html
PS: you can download CFML Reference Manual and CF Dev Guide free PDFs from adobe.com if you do not have them: http://www.adobe.com/support/documentation/en/coldfusion/
as for your questions:
>> is there a way to create [a folder] via a form and coldfusion?
yes, there is. check out <cfdirectory action="create"> tag:
<cfdirectory>: http://livedocs.adobe.com/coldfusion/8/Tags_d-e_03.html
using <cfdirectory>: http://livedocs.adobe.com/coldfusion/8/manageFiles_7.html
>> example of how to use cffile to upload multiple documents at one time and store the name into the database?
read these:
http://www.bennadel.com/blog/1117-Ask-Ben-Uploading-Multiple-Files-Using-ColdFusion.htm
http://www.devarticles.com/c/a/ColdFusion/Multiple-File-Upload-with-CFFILE/
https://www.experts-exchange.com/questions/23730630/coldfusion-multiple-file-upload.html
Azadi
Yes, definitely get yourself a copy of livedocs or bookmark it in your browser. Most likely you will use it on a daily basis.
SOT:
http://www.cfquickdocs.com/cf8/
same content (sans comments) as livedocs, and about 1000 times faster...
plus a FF search plug-in!
great for quick look-ups of tag/function syntax (though i personally tend to just have the CFML reference PDF open...)
Azadi
http://www.cfquickdocs.com/cf8/
same content (sans comments) as livedocs, and about 1000 times faster...
plus a FF search plug-in!
great for quick look-ups of tag/function syntax (though i personally tend to just have the CFML reference PDF open...)
Azadi
> plus a FF search plug-in!
Sweet! I did not know they had a plugin.
Sweet! I did not know they had a plugin.
ASKER
_agx_: I'm able to get your code to work (thank you exactly what I'm looking for). But I can't get the file name to be stored in the database with a file extension (example: myfile.pdf is stored as myfile) is there a work around for this? I'm using mySQL
ASKER
I think I found it.. in the portion of the code: <cfqueryparam value="#cffile.serverFileN ame#" cfsqltype="cf_sql_varchar" > I changed the .serverFileName to .serverFile and it worked! Is there a disadvantage to doing this?
> Is there a disadvantage to doing this?
jasch2244, sorry that was a typo. No there is no disadvantage. It is strictly a matter of using whichever field you need for your purposes. In your case, yes, you want the one with the file extension.
jasch2244, sorry that was a typo. No there is no disadvantage. It is strictly a matter of using whichever field you need for your purposes. In your case, yes, you want the one with the file extension.
Yes. You can use the cfdirectory tag to create folders on your server.
Question two: Do you have an example of how to use cffile to upload multiple documents at one time and store the name into the database?
See my example above. It creates a form with 5 file fields with the names uploadFile1, uploadFile2, ...., uploadFile5. (But you can create as few or as many as you want). When the form is submitted, it uses a a loop to process each of the files:
- First it uses cffile to upload each file
- Uses cfquery to insert the file _name_ (ie someFile.jpg) into a database table. Just replace the datasource, table and column names with your own.