Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to <cfoutput> an inmage and upgrade it

Status
Not open for further replies.

auriga69

Technical User
Feb 11, 2001
9
0
0
CL
I have two questions, and I'm a newbie in CF, so be patient.
1.- I'm ok on upload an image an positioning it in an specific folder.
But when I tried to <cfoutput> gave me an error.
========
This is my action page for record:
<CFFILE ACTION=&quot;Upload&quot; FILEFIELD=&quot;noticia_foto&quot; DESTINATION=&quot;c:\inetpub\ NAMECONFLICT=&quot;MakeUnique&quot;>
<cfquery datasource=&quot;portal&quot;>
insert into noticias
(noticia_epigrafe,noticia_titulo,noticia_lead,category_id,noticia_cuerpo,fecha_posteo, fecha_expiracion) values
('#form.noticia_epigrafe#','#form.noticia_titulo#','#form.noticia_lead#','#form.category_id#','#form.noticia_cuerpo#','#form.fecha_posteo#','#form.fecha_expiracion#')
</cfquery>
========
This is the form that modifies the data, extract it and modify it.
<cfquery name=&quot;qry_noticia_alterar&quot; datasource=&quot;portal&quot;>
select * from noticias
where noticia_id = #url.noticia_id#
</cfquery>
<cfoutput query=&quot;qry_noticia_alterar&quot;>
<form action=&quot;update.cfm&quot;...etc>
<tr bgcolor=&quot;##003366&quot;>
<td>
<blockquote>
<p>Fotografía:</p>
</blockquote>
</td>
<td><input type=&quot;file&quot; name=&quot;noticia_foto&quot; value=&quot;#qry_noticia_alterar.noticia_foto#&quot;>
</td>
</tr>
</form>
</cfoutput>
And obvoiusly between a form action, etc.
I would like to extract the picture, image either before you could change it to other image.
====
But this page gave an error in upgrade action
I used this page (update.cfm) to do that
<CFFILE ACTION=&quot;Upload&quot; FILEFIELD=&quot;noticia_foto&quot; DESTINATION=&quot;c:\inetpub\ NAMECONFLICT=&quot;overwrite&quot; >
<cfquery datasource=&quot;portal&quot;>
update noticias
set noticia_epigrafe = '#form.noticia_epigrafe#',
noticia_titulo = '#form.noticia_titulo#',
noticia_lead = '#form.noticia_lead#',
category_id = '#form.category_id#',
noticia_cuerpo = '#form.noticia_cuerpo#',
fecha_expiracion = '#form.fecha_expiracion#'
where noticia_id = #form.noticia_id#
</cfquery>
=============
I would like to store an image then extract it and see if the correct so I could have the possibility to change it and upload another. That it's the only thing I want.

Thanks in advance
;-)
 
I see that you are uploading your photos but not storing the file names in your database. If you don't do that then you are uploading images but they do not get associated with your data. Try this for the INSERT part:
Code:
<CFFILE ACTION=&quot;Upload&quot; FILEFIELD=&quot;noticia_foto&quot; DESTINATION=&quot;c:\inetpub\[URL unfurl="true"]wwwroot\portal\fotos\&quot;[/URL]                NAMECONFLICT=&quot;MakeUnique&quot;>
<cfquery datasource=&quot;portal&quot;>
    insert into noticias
    (noticia_epigrafe,noticia_titulo,noticia_lead,category_id,noticia_cuerpo,fecha_posteo, fecha_expiracion, noticia_foto) values
    ('#form.noticia_epigrafe#','#form.noticia_titulo#','#form.noticia_lead#','#form.category_id#','#form.noticia_cuerpo#','#form.fecha_posteo#','#form.fecha_expiracion#', '#FILE.ServerFile#')
</cfquery>
Then you should have a file name stored in that row. I'm assuming that noticia_foto is a CHAR or VARCHAR or TEXT or whatever you need for your particular database.

SUGGESTIONS:

Just store the file name in the database, don't store directory information. This way you can move files or change directories and not have to modify your database.

Don't store binary in your database -- don't store the actual files but the file names only. Much faster and easier on the system.

You are telling the server to &quot;MakeUnique&quot; which means you need to get FILE.ServerFile as the file name. Look in your CF documentation, this is the name that CF is setting to your uploaded file, which is not necessarily the name of the file you uploaded!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top