Home: Perl Programming Help: Beginner:
Uploading (file modes)



scuffed
stranger

May 29, 2001, 1:49 PM


Views: 941
Uploading (file modes)

ok i dont get the bunmode() stuff and how do i upload in ASCII mode? i know binmode is for binary (i think)
if anyoen can help me out please do.
i have
open(FILE, $filename)
binmode(FILE)
and so fourth
if you could give me a very precise example thank you



mhx
Enthusiast / Moderator

May 29, 2001, 2:21 PM


Views: 938
Re: Uploading (file modes)

Hi,

what exactly are you trying to do? If you want a precise answer, you've got to ask a precise question...
Do you want to open a file in binary mode (that's what the code looks like) or do you want to use perl to handle FTP up-/downloads? If the last one is the case, use the Net::FTP package available on CPAN.

-- Marcus



scuffed
stranger

May 29, 2001, 5:53 PM


Views: 937
Re: Uploading (file modes)

ok well i made a small file manager thingy and i tried to make a stupid upload for it and when i went to upload a .CGI file it wouldn't run on the server until i used flash fxp to upload it in the mode it needed ot be uploaded in



mhx
Enthusiast / Moderator

May 29, 2001, 11:39 PM


Views: 933
Re: Uploading (file modes)

That's not what I would call a precise question (if any), but let's give it another try. You've written a file manager in Perl. You can use the file manager for uploads. If you upload a CGI script, it won't run. The file manager is actually also a CGI script running on your server and you use a browser to select a file and upload it. (Let's see what else comes to my mind... hey, let me guess what you got for lunch...)
If the above should be correct, and you are running Windows, but your server is running some flavor of Unix, the problem is obviously the CR/LF sequence at the end of each line in the CGI script. You can handle this e.g. by using a search and replace pattern on the whole file before saving it:

Code
$file =~ s/\r\n/\n/g;

Obviously, you should make this optional in your file manager, because only text files need this conversion.

-- Marcus