?
Solved

Delete file with a button

Posted on 2008-06-25
2
Medium Priority
?
152 Views
Last Modified: 2013-12-16
Hello experts.
I have one update page where i'm uploading and deleting images.
For the delete function i use a checkbox.
Instead of that can i use a button?
<CFSET thispath = expandpath("./images")>
  <cfif structKeyExists(form,"foto1") and len(form.foto1)><!--- uploads a file to our website --->
  <CFFILE action="upload" filefield="foto1" destination="#thispath#" nameconflict="MAKEUNIQUE">
    <cfimage name="uploadedImage"
   source="#thispath#/#cffile.serverFile#" >
   ......
   .....
   <CFSET ServerFile1 = FILE.SERVERFILE></cfif>
 
   <cfif isdefined ("Deletimg_1")>
   <cffile action="delete" file="#thispath#/#artikel.Photo1#">
   <cfset ServerFile1 = images_1.jpg>
   </cfif>
   <CFFILE action="upload" filefield="foto2" destination="#thispath#" nameconflict="MAKEUNIQUE">
   <cfimage name="uploadedImage"
   source="#thispath#/#cffile.serverFile#" >
   ......
   ......
   <CFSET ServerFile2 = FILE.SERVERFILE>
  </cfif>
  
<cfquery name="artikel" datasource="#dsn#">
SELECT a.Art_ID, a.Photo1, a.Photo2
FROM dbo.artikel a 
WHERE Art_ID = <cfqueryparam value="#URL.Art_ID#" cfsqltype="cf_sql_numeric"> OR ( -1= <cfqueryparam value="#WADA_URL_Art_ID#" cfsqltype="cf_sql_numeric"> AND Art_ID=<cfqueryparam value="#SESSION.WADA_Insert_dboartikel#" cfsqltype="cf_sql_numeric">) 
</cfquery> 
 
<cfparam name="SERVERFILE1" default="">
<cfparam name="SERVERFILE2" default="">
 
<cfif CGI.REQUEST_METHOD IS "POST">
<cfinclude template="Includes/uploadhelper.cfm">
<cfquery name="imageupload" datasource="#dsn#">
Update dbo.artikel
SET photo1 =<Cfif len(ServerFile1)>'#ServerFile1#'<cfelse>photo1</cfif>,
    photo2 =<Cfif len(ServerFile2)>'#ServerFile2#'<cfelse>photo2</cfif>
   
   Where Art_Id= <cfqueryparam value="#URLEncodedFormat(artikel.Art_ID)#"> 
</cfquery>
<cflocation url="InsertPhoto.cfm?Art_ID=#URLEncodedFormat(artikel.Art_ID)#">
</cfif>
 
 
<form action="#CGI.SCRIPT_NAME#" method="post" enctype="multipart/form-data" name="UpdateForm" id="UpdateForm">
<input name="imageField" type="image" id="imageField" src="images/<cfoutput>#artikel.Photo1#</cfoutput>" align="left" width="80" height="60" />
<input name="foto1" class="textfieldfoto" type="file" size="20" /><input type="checkbox" name="Deletimg_1" id="Deletimg_1"  value="1"/>Delete<br>
<input name="imageField2" type="image" id="imageField2" src="images/<cfoutput>#artikel.Photo2#</cfoutput>" align="left" width="80" height="60" />
<input name="foto2" class="textfieldfoto" type="file" size="20" />
<input type="submit"  lang="de"  height="30" width="60" name="update" id="update" value="Upload" />
</form>

Open in new window

0
Comment
Question by:Panos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 63

Accepted Solution

by:
Zvonko earned 2000 total points
ID: 21896813
Change this:
<input type="checkbox" name="Deletimg_1" id="Deletimg_1"  value="1"/>Delete<br>

To this:
<input type="submit" name="Deletimg_1" id="Deletimg_1"  value="Delete" ><br>


0
 
LVL 2

Author Closing Comment

by:Panos
ID: 31470521
Hi Zvonko.
Thank you again for your help.
regards
panos
0

Featured Post

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question