Gossamer Forum
Home : Products : Others : Fileman :

gif vs. jpg uploads??

Quote Reply
gif vs. jpg uploads??
Hello,
When trying out fileman I got it working
fine except If I upload gif files of any
size they display fine in the browser, but,
if i upload jpg files they display all scrambled in the browser. Any idea why? I'm
on a Unix box with Apache server.

Also, I did a little testing and found out something interesting:
If I upload a jpg as a jpg it doesn't display.
If I upload a jpg but name the remote name a gif, it displays.
If I then rename it to jpg it still displays fine.
It appears to have something to do with the jpg exstension. maybe it transfers it ASCII??

Well, still working on it, now something stranger:
I can upload a jpg file but name the remote
name even .txt and then use fileman to rename
it back to .jpg and it displays fine!

What gives?

wierd!

Thanks in Advance,
fsumarc

[This message has been edited by fsumarc (edited February 04, 1999).]

[This message has been edited by fsumarc (edited February 04, 1999).]
Quote Reply
Re: gif vs. jpg uploads?? In reply to
Are you uploading this in ASCII mode or Binary mode?



Daniel J.
Quote Reply
Re: gif vs. jpg uploads?? In reply to
I'm uploading with the script which I'm assuming is uploading it in binary mode.
That's what the problem is: any file with
a .jpg extension will not upload correctly
through the script on my server. (Apache 1.3.2) I tested in the demo and seems to work fine.
Quote Reply
Re: gif vs. jpg uploads?? In reply to
Hi!

Change:

($fullfile =~ /[cgi|pl]$/) and ($buffer =~ s/\r//g);

to:

($fullfile =~ /cgi|pl$/) and ($buffer =~ s/\r//g);

and it should work (in sub upload around line 688). Sorry about that!

Alex
Quote Reply
Re: gif vs. jpg uploads?? In reply to
Sweet!
Thanks Alex!
Worked Perfectly!
Great script by the way.
Have you looked into a way to do multiple
uploads at once? that would basically top
off the script to perfection!

Thanks again,
Marc
Quote Reply
Re: gif vs. jpg uploads?? In reply to
Hi

I have had reports of a similar thing happening with Excel files - is this the same problem?

Chris
Quote Reply
Re: gif vs. jpg uploads?? In reply to
Hi Chris,

Yes.. My reg expression was wrong:

($fullfile =~ /[cgi|pl]$/)

means match anything ending in a c, g, i, p, or l will be uploaded in ascii mode. It should have been anything ending in 'cgi' or 'pl' of course. So a .xl file will be corrupted.

Cheers,

Alex


Quote Reply
Re: gif vs. jpg uploads?? In reply to
Alex,

Are you talking about the same script as that which is downloadable? I have searched and searched throughout sub upload and cannot find that line in it to change. In fact, cgi|pl doesn't come up in a search of the whole script at all. What am I missing?

------------------
Bob Connors
bobsie@orphanage.com
www.orphanage.com/goodstuff/
goodstufflists.home.ml.org/



[This message has been edited by Bobsie (edited February 13, 1999).]
Quote Reply
Re: gif vs. jpg uploads?? In reply to
Hi,
look at about the 19th line after the
start of the sub upload, you should see this:


while ($bytesread=read($data,$buffer,1024)) { ($fullfile =~ /cgi|pl$/) and ($buffer =~ s/\r//g);
print OUTFILE $buffer;


that is the location to make the change mentioned above.

Hope this helps,
fsumarc
Quote Reply
Re: gif vs. jpg uploads?? In reply to
 
Quote:
while ($bytesread=read($data,$buffer,1024)) { ($fullfile =~ /cgi|pl$/) and ($buffer =~ s/\r//g);
print OUTFILE $buffer;

I don't have that code in mine. Mine says:

Quote:
# Open the output file and save the upload. We abort if the file is
# to big, or not enough free disk space.
open (OUTFILE, ">$fullfile") or &cgierr ("Can't open: '$fullfile'.\nReason: $!");
binmode (OUTFILE); # For those O/S that care.
while ($bytesread=read($data,$buffer,1024)) {
print OUTFILE $buffer;

I checked the version number of the script and it says version 1.0, the same as is online here for download. Was the archive changed and my code is no longer right?

------------------
Bob Connors
bobsie@orphanage.com
www.orphanage.com/goodstuff/
goodstufflists.home.ml.org/


Quote Reply
Re: gif vs. jpg uploads?? In reply to
My version code also says 1.0 but I only downloaded a few days ago. how long have you had yours? If it's been a while, I would re-download it and install the new script. But I don't know what all the changes have been.
If you have a good editor you can do a compare and see. maybe make a backup and then install it. see if it works..

Alex? any suggestions?

Good luck,
fsumarc

p.s. just in case. here's my whole upload
subroutine if you want to copy and paste:


sub upload {
# -----------------------------------------------------
# Begin Upload File Procedure:

my ($directory, $data, $filename, $free_space) = @_;
my ($bytesread, $buffer, $fullfile, $file_size);

# Make sure we have a filename to upload.
(!$filename) and return (0, "Upload: No filename was entered!");

# Get the full file name.
($directory =~ m,/$,) ?
($fullfile = "$directory$filename") :
($fullfile = "$directory/$filename");
$file_size = 0;

# Open the output file and save the upload. We abort if the file is
# to big, or not enough free disk space.
open (OUTFILE, ">$fullfile") or &cgierr ("Can't open: '$fullfile'.\nReason: $!");
binmode (OUTFILE); # For those O/S that care.
while ($bytesread=read($data,$buffer,1024)) {
($fullfile =~ /cgi|pl$/) and ($buffer =~ s/\r//g);
print OUTFILE $buffer;
$file_size += 1024;
if (($file_size / 1000) > $free_space) {
close OUTFILE;
unlink ($fullfile) or &cgierr ("Can't unlink: $fullfile. Reason: $!");
return (0, "Upload: Not enough free space to upload that file. Space left: $free_space kb.");
}
if (($file_size / 1000) > $config{'max_upload'}) {
close OUTFILE;
unlink ($fullfile) or &cgierr ("Can't unlink: $fullfile. Reason: $!");
return (0, "Upload: Aborted as your file is larger then the maximum uploadable file size of $config{'max_upload'} kb!");
}
}
close OUTFILE;
&exists($fullfile) ?
return (int($file_size / 1000), "Upload: '$filename' uploaded.") :
return (int($file_size / 1000), "Upload: Cannot upload '$filename'. Check permissions.");
}
Quote Reply
Re: gif vs. jpg uploads?? In reply to
Now I am really confused! I just downloaded the fileman.zip again, extracted it to a different directory, loaded it up and compared it against the other one I had downloaded back in Dec 98, and guess what? They are identical! So now the question is, where did that code come from and why is it in yours, but not in either of mine? I re-read this thread and see no mention of multi vs single user version, so that can't be it.

Alex? Can you help here?

------------------
Bob Connors
bobsie@orphanage.com
www.orphanage.com/goodstuff/
goodstufflists.home.ml.org/


Quote Reply
Re: gif vs. jpg uploads?? In reply to
Sorry about the confusion. When I moved servers, I had copied 1.0 over, then updated the script on the old server, not the new one.

In any respect, it's up there now with the fixed regexp labeled as 1.01.

Cheers,

Alex