Gossamer Forum
Quote Reply
Image upload space issue
Hello all,

I am using global imageurl to let people upload their logo or image as needed. I am running into people who do not know how to properly format an image name. (no spaces). SO when someone uploads an image with a space in the name the image does not shows up.

Does anyone have any suggestions on how to fix this issue?
Code:
sub {
my $field = shift;
my $tags = GT::Template->tags;
my $id = $tags->{ID};
if ($tags->{$field})
{

my $links_db = $DB->table('Links');
my $fh = $links_db->file_info( "$field", $id );
return "" unless($fh);

my $location = $fh->File_RelativePath;
my $logow = 75;
my $extra_atts="oriw=$tags->{LogoWidth}";
if($field eq "Logo" && $tags->{LogoWidth} ne "$logow"){
eval{
use Image::Magick;
};
$@ and return $@;

my $i= new Image::Magick();
my $if = $CFG->{build_root_path} . "/upload$location";

my $error = $i->Read($if);
return "Could not read $if file. Reason:" . $error if $error;

my $w = $i->Get('width');
$extra_atts .= ";width =$w";
if($w ne "$logow"){
my $h = $i->Get('height');

my $logoh = int($h*($logow/$w));
$error = $i->Resize(geometry => "${logow}x$logoh", width => $logow, height => $logoh);
return "Could not read $if file. Reason:" . $error if $error;
$extra_atts .= ";height=$h";
my $rs = $i->Write($if);

}

$links_db->update({LogoWidth => $logow},{ID => $id}) if($tags->{LogoWidth} ne "$logow");

}


return qq~$CFG->{build_root_url}/Upload_Image$location~;
}
else
{
return "";
}
}
The form used:
<input class="text" type="file" id="Upload_Image" name="Upload_Image" value="" size="30">


Thanks for any help on this :)


Sandra Roussel
Chonsa Group Design - Fresh Start Housing

Last edited by:

SandraR: Feb 8, 2007, 9:19 PM
Subject Author Views Date
Thread Image upload space issue SandraR 7016 Feb 8, 2007, 9:17 PM
Thread Re: [SandraR] Image upload space issue
brewt 6893 Feb 8, 2007, 10:15 PM
Thread Re: [brewt] Image upload space issue
SandraR 6879 Feb 9, 2007, 8:25 PM
Thread Re: [SandraR] Image upload space issue
SandraR 6835 Feb 16, 2007, 10:45 AM
Thread Re: [SandraR] Image upload space issue
SandraR 6838 Feb 21, 2007, 8:02 AM
Post Re: [SandraR] Image upload space issue
brewt 6792 Feb 21, 2007, 1:53 PM
Thread Re: [SandraR] Image upload space issue
brewt 6836 Feb 21, 2007, 4:23 PM
Thread Re: [brewt] Image upload space issue
SandraR 6800 Mar 5, 2007, 9:48 AM
Thread Re: [SandraR] Image upload space issue
brewt 6770 Mar 5, 2007, 2:36 PM
Thread Re: [brewt] Image upload space issue
SandraR 6771 Mar 5, 2007, 2:43 PM
Thread Re: [SandraR] Image upload space issue
brewt 6769 Mar 5, 2007, 4:03 PM
Post Re: [brewt] Image upload space issue
SandraR 6761 Mar 5, 2007, 4:47 PM
Thread Re: [SandraR] Image upload space issue
brewt 6770 Mar 5, 2007, 5:49 PM
Post Re: [brewt] Image upload space issue
SandraR 6705 Mar 13, 2007, 5:17 PM