Author Topic: HACK: Remove uploaded file from CSVedit.  (Read 1963 times)

0 Members and 1 Guest are viewing this topic.

Offline irocwebs

  • Jr. Member
  • **
  • Posts: 24
    • Iroc Web Design Services
HACK: Remove uploaded file from CSVedit.
« on: May 31, 2011, 07:37:18 PM »
Use at your own risk. Make a backup of your script(s) before making any changes.

This will allow you to remove uploaded files (just the data) from the database field. NOTE: This will not remove the file from the server itself, just the data.

In CSVedit.pl, go to the sub edit function (around line 464) and replace this:

Code: [Select]
elsif($FileUploadFileds{$_}){
                                $text .=  qq~<a href="$fileURL/$line[$a]" target="_blank">$line[$a]</a><br>~ if $line[$a];
$text .=  qq|<input type=file name="$_">|;
}

with this:

Code: [Select]
elsif($FileUploadFileds{$_}){
                                $text .=  qq~<input type="checkbox" name="$_" value="">Check to remove file. [ <a href="$fileURL/$line[$a]" target="_blank">$line[$a]</a> ]<br>~ if $line[$a];
$text .=  qq|<input type=file name="$_" id="$_">|;
}

Basically how it works, is by checking the box, it passes the value of nothing to the database. This is especially nice if you need to remove uploaded files, but don't want to delete the record and recreate it every time you need to do it.

Good Luck!

Cori

Offline Jason

  • Administrator
  • Hero Member
  • *****
  • Posts: 1018
    • slipdex
Re: HACK: Remove uploaded file from CSVedit.
« Reply #1 on: June 03, 2011, 02:56:50 PM »
Cori,

Think something similar could be done in the update script so the user could delete files?

Jason
Founder of www.slipdex.com

Offline irocwebs

  • Jr. Member
  • **
  • Posts: 24
    • Iroc Web Design Services
Re: HACK: Remove uploaded file from CSVedit.
« Reply #2 on: June 06, 2011, 12:02:46 AM »
Here you go Jason. Let me know if it works.

NOTE: This is untested... but should work.

Use at your own risk. Make a backup of your script(s) before making any changes.

This will allow you to remove uploaded files (just the data) from the database field. NOTE: This will not remove the file from the server itself, just the data.

In CSVupdate.pl, go to the sub edit function (around line 355) and replace this:

Code: [Select]
elsif($images{$_}){
        $text .=  qq~<a href="$fileURL/$data{$_}" target="_blank">$data{$_}</a><br>~ if $data{$_};
$text .=  qq~<input type=file name="$_">~;
$text .=  qq~<small>&nbsp;leave blank if not need change<small>~ if $data{$_};
}

with this:

Code: [Select]
elsif($images{$_}){
        $text .=  qq~<input type="checkbox" name="$_" value="">Check to remove file. [ <a href="$fileURL/$data{$_}" target="_blank">$data{$_}</a>]<br>~ if $data{$_};
$text .=  qq~<input type=file name="$_">~;
$text .=  qq~<small>&nbsp;leave blank if not need change<small>~ if $data{$_};
}

Good luck!

Cori