[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date
][Minivend by thread
]
Re: Delete image w/ database record
****** message to minivend-users from Frank Miedreich <miedreich@acm.org> ******
> Hi All, I have it set up so that my clients can add / edit /
>remove items without my intervention, and upload image files as well.
>The image files are always in the same directory and are named using
>[item-code].jpg What I would like to do now is have it so that when
>they remove the item from the database it also deletes the image. All of
>this is in a password protected directory so security isn't a major
>concern. I had considered using a SSI with an EXEC and "rm -f
>/full/path/[item-code].jpg", but I don't think you can use a normal SSI in
>a catalog page. Any suggestions. Thanks, Brian T. Allen
>brian@purenetfx.com
The perl command to delete a file is unlink.
write a globalsub or usertag using "unlink" to delete the file from the
server. It would have to go into minivend.cfg, as unlink is trapped by Safe.
To get you started:
--- snip ---
UserTag destroy hasEndTag 0
UserTag destroy interpolate 1
UserTag destroy Order filename
UserTag destroy Routine <<EOF
sub {
my ($filename) = @_;
unlink $filename;
}
EOF
--- snip ---
call with [destroy filename="/full/path/[item-code].jpg"] from your page.
Including error checking and other sensible stuff in perl code is
advisable, e.g. protecting yourself from wildcards.
I do like the statement about password protection and security. I'll submit
it to the "Famous Last Words" file.
Frank
--
Frank Miedreich
Max-Planck-Institut fuer psychologische Forschung
-
To unsubscribe from the list, DO NOT REPLY to this message. Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list