• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

cffile and uploading images

LEGEND ,
Aug 03, 2006 Aug 03, 2006

Copy link to clipboard

Copied

I am a little bit confused on creating a form that can upload an image to a
folder. I am using the cffile tag and have a file field on the form to allow
the user to browse and file a logo to upload. I have it all set up but do I
use the copy or upload?

I have this:
<cffile action="copy" accept="jpg,jpeg,png,gif,psd" destination="logos"
filefield="logo" nameconflict="makeunique"> but then I noticed the 'upload'
attribute to the action.

Thanks
--
Wally Kolcz
Developer / Support


TOPICS
Advanced techniques

Views

495

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 03, 2006 Aug 03, 2006

Copy link to clipboard

Copied

Figured it out. However I have another question.
How can I just capture just the name of the file and not the complete path?


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 05, 2006 Aug 05, 2006

Copy link to clipboard

Copied

Cffile.Serverfile will return filename and extension
cffile.serverfileext will return file extension only
cffile.serverfilename will only return filename without extension

Also, do a CFDUMP on CFFILE afterwards to see all the option you can use.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 05, 2006 Aug 05, 2006

Copy link to clipboard

Copied

Thanks for the heads up on these. I have been searching the docs, but I
can't find an example on how to use them. I want to use te cffile.serverfile
to return the file name and extension. Do I use that during the upload
process? If so, how to you add it to the statement?

<cffile action="upload" accept="image/gif, image/jpeg, image/jpg, image/png,
image/psd" destination="E:\webs\website.com\main\clients\logos"
filefield="form.logo" nameconflict="makeunique">

would it be:

<cffile.serverfile action="upload" accept="image/gif, image/jpeg, image/jpg,
image/png, image/psd" destination="E:\webs\website.com\main\clients\logos"
filefield="form.logo" nameconflict="makeunique">


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 05, 2006 Aug 05, 2006

Copy link to clipboard

Copied

Ok, I gathered that it is not how you use it. I see how you can use it to
show the file name in an <cfoutput>

How can I use this parameter to ensure that only the filename and extension
are being entered into the database? Would I use that in the INSERT
statement?

Thanks.


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 06, 2006 Aug 06, 2006

Copy link to clipboard

Copied

LATEST
Yes.
Do your query as such:

<cfquery datasource="DSN">
Insert into Tablename(image_name)
Values('#cffile.serverfile#")
</cfquery>

Adjust to what your db tables, etc are called.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation