Gossamer Forum
Home : Products : Links 2.0 : Customization :

Re: [LILHOMIE] Here's a working image upload mod!

Quote Reply
Re: [LILHOMIE] Here's a working image upload mod! In reply to
It's been several years since I did all that, it's kinda of fuzzy, but I do have all the files I worked with so I should be able to figure out what's happening. Let's simplify, and just have one upload and no checkbox for now...

Change this...
Code:
<%if Image_1%>
<tr><td align="right" valign="top">Current Image 1:</td>
<td><img src="<%build_upload_url%>/<%Image_1%>" /><div class="formhelp">[<%Image_1%>]</div></td></tr>

<%endif%>
<tr><td align="right" valign="top">Delete Image 1? <input type="checkbox" name="image_1_delete" value="yes"></td></tr>
<tr><td align="right" valign="top">Image 1</td>
<td><input name="Image_1" type="file" value="" /><input type="hidden" name="Image_1_Transfer" value="<%Image_1%>" /></td></tr>
<tr><td align="right" valign="top">Caption 1:</td>
<td><textarea wrap="virtual" input name="Caption_1" value="" rows="3" cols="42"><%Caption_1%></textarea></td></tr>


<%if Image_2%>
<tr><td align="right" valign="top">Current Image 2:</td>
<td><img src="<%build_upload_url%>/<%Image_2%>" /><div class="formhelp">[<%Image_2%>]</div></td></tr>
<%endif%>
<tr><td align="right" valign="top">Delete Image 2?</td>
<td><input type="checkbox" name="image_2_delete" value="yes"></td></tr>

<tr><td align="right" valign="top">Image 2</td>
<td><input name="Image_2" type="file" value="" /><input type="hidden" name="Image_2_Transfer" value="<%Image_2%>" /></td></tr>
<tr><td align="right" valign="top">Caption 2:</td>
<td><textarea wrap="virtual" input name="Caption_2" value="" rows="3" cols="42"><%Caption_2%></textarea></td></tr>

To this...
Code:

<%if Image_1%>
<tr><td align="right" valign="top">Current Image 1:</td>
<td><img src="<%build_upload_url%>/<%Image_1%>" /> </td></tr>

<%endif%>
<tr><td align="right" valign="top">Image 1</td>
<td><input name="Image_1" type="file" value="" /><input type="hidden" name="Image_1_Transfer" value="<%Image_1%>" /></td></tr>
<tr><td align="right" valign="top">Caption 1:</td>
<td><textarea wrap="virtual" input name="Caption_1" value="" rows="3" cols="42"><%Caption_1%></textarea></td></tr>

Don't worry about changing links.def or the data files.
Image_1: $original{'Image_1'} Just a question, shouldn't this be $in instead of $original ? Probably...

Change this...
Code:
## LT added 'if delete_image' here...
if (($in{'image_' . $fnum . '_delete'} eq "yes") &&
(length($in{'Image_' . $fnum . '_Transfer'}) > 1)) {
# So first remove any previously uploaded files in that file(x) position
unlink "$upload_path/$in{'Image_' . $fnum . '_Transfer'}";
} # close LT 'if delete_image'
else { #LT
&site_html_modify_failure("To replace an existing image you need to check the \'delete image\' box.") and return;
} # close LT 'else'
# Now let's go ahead and upload that new file
# changed to append Link ID instead of random number >
$file_name = $in{$db_key} . $file_name; # Prevent files being overwritten by appending Link ID
# < changed to append Link ID

to this:
Code:
# Now let's go ahead and upload that new file

I'm having trouble getting the link ID in add.cgi, as the file is names before the form is parsed, so ID does not work. Works in modify, since the link is already numbered.

For the security mod,it's much simpler to kill the reversal thing; remove this: my $reversed = reverse $in{'Password'};
and change this: if (($data[$db_user] eq $in{'Username'}) and ($data[$db_pw] eq $reversed)) {
to: if (($data[$db_user] eq $in{'Username'}) and ($data[$db_pw] eq $in('Password'))) {

Usually try only one mod at a time, or you'll bury yourself in confusing code changes!

Gotta run right now, see what these changes do for you...


Leonard
aka PerlFlunkie
Subject Author Views Date
Thread Here's a working image upload mod! PerlFlunkie 22395 Feb 17, 2005, 9:55 PM
Thread Re: [PerlFlunkie] Here's a working image upload mod!
PerlFlunkie 22030 Feb 17, 2005, 11:11 PM
Thread Re: [PerlFlunkie] Here's a working image upload mod!
jayman 21760 Nov 4, 2005, 5:57 AM
Thread Re: [jayman] Here's a working image upload mod!
PerlFlunkie 21770 Nov 4, 2005, 2:40 PM
Thread Re: Here's a working image upload mod!
LILHOMIE 21101 Nov 8, 2009, 4:50 PM
Post Re: [LILHOMIE] Here's a working image upload mod!
LILHOMIE 21095 Nov 8, 2009, 7:50 PM
Thread Re: [LILHOMIE] Here's a working image upload mod!
PerlFlunkie 21116 Nov 8, 2009, 8:01 PM
Post Re: [PerlFlunkie] Here's a working image upload mod!
LILHOMIE 21123 Nov 8, 2009, 9:13 PM
Thread Re: [PerlFlunkie] Here's a working image upload mod!
LILHOMIE 21153 Nov 8, 2009, 10:16 PM
Thread Re: [LILHOMIE] Here's a working image upload mod!
PerlFlunkie 21087 Nov 9, 2009, 9:50 AM
Thread Re: [PerlFlunkie] Here's a working image upload mod!
LILHOMIE 21032 Nov 11, 2009, 6:53 AM
Thread Re: [LILHOMIE] Here's a working image upload mod!
PerlFlunkie 21022 Nov 11, 2009, 8:58 AM
Thread Re: [PerlFlunkie] Here's a working image upload mod!
LILHOMIE 21053 Nov 11, 2009, 3:40 PM
Thread Re: [LILHOMIE] Here's a working image upload mod!
LILHOMIE 21009 Nov 11, 2009, 3:53 PM
Thread Re: [LILHOMIE] Here's a working image upload mod!
PerlFlunkie 20994 Nov 11, 2009, 5:15 PM
Thread Re: [PerlFlunkie] Here's a working image upload mod!
LILHOMIE 20958 Nov 12, 2009, 9:13 PM
Thread Re: [LILHOMIE] Here's a working image upload mod!
PerlFlunkie 20889 Nov 14, 2009, 3:06 PM
Post Re: [PerlFlunkie] Here's a working image upload mod!
PerlFlunkie 20594 Nov 24, 2009, 5:38 PM
Post Re: [LILHOMIE] Here's a working image upload mod!
LILHOMIE 21046 Nov 11, 2009, 5:12 PM