Hi all,
I have a dbman install which has been running fine for over a year now. My query concerns the image upload mod and deleting the associated image BUT not the record. On the odd occasion whe the client needs to REMOVE an image i have just been uploading a 1x1 transparent gif, yeh i know, lazy
However i would like to fix this.
I have an outline below and was hoping for a few pointers from you code junkies out there as to if it was a feasible plan or just complete madness
I'm a little rusty having not touched DBman for a good while so be gentle
I'm sure lots of you must have created a DELETE button?
1) Create a new field in database called 'DeleteImage'
%db_checkbox_fields = (
'DeleteImage' => 'yes'2) Add the extra field to all existing database records, ouch!
3) Add a checkbox called 'DeleteImage' in 'sub html_record_form' in html.pl
<TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><b>Delete Image:</b></TD>
<TD VALIGN="TOP" WIDTH="80%"> |;
print &build_checkbox_field("DeleteImage",$rec{'DeleteImage'});
print qq|</TD></TR> .....4) Insert this code **SOMEWHERE** in 'sub add_record' in 'db.cgi' so it gets executed when a record with an image is submitted. (this is the bit I can't really grasp where toput it)
unlink ("$file_upload_dir/$db_key.$ext");
}5) Cross fingers and test
Thanks in advance for your time!
I have a dbman install which has been running fine for over a year now. My query concerns the image upload mod and deleting the associated image BUT not the record. On the odd occasion whe the client needs to REMOVE an image i have just been uploading a 1x1 transparent gif, yeh i know, lazy
I have an outline below and was hoping for a few pointers from you code junkies out there as to if it was a feasible plan or just complete madness
1) Create a new field in database called 'DeleteImage'
Code:
'DeleteImage' => [ 10, 'alpha', 0, 3, 0, '', '']Code:
# Checkbox fields. Field name => Checkbox value. %db_checkbox_fields = (
'DeleteImage' => 'yes'
3) Add a checkbox called 'DeleteImage' in 'sub html_record_form' in html.pl
Code:
..... <TR class="bodycopy"> <TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><b>Delete Image:</b></TD>
<TD VALIGN="TOP" WIDTH="80%"> |;
print &build_checkbox_field("DeleteImage",$rec{'DeleteImage'});
print qq|</TD></TR> .....
Code:
if ($in{'DeleteImage'} eq "yes") { unlink ("$file_upload_dir/$db_key.$ext");
}
Thanks in advance for your time!

