|
-
Jan 27th, 2005, 03:27 PM
#1
Thread Starter
Addicted Member
Need some help with "Upload.pl".[Solved]
Hello.
I know nothing about cgi and perl, but i got this uploading script and i need help with two changes if they are possible to make.
1. How can i make "enter" or "new line" after printing this?
print ff $in;
2. It will save all uploaded txtfiles as "SAVE.txt", would like it beter if it was saved as the 5 first letters inside the uploaded txtfile "@inx".
Code:
#!/usr/bin/perl
use CGI;
$CGI::POST_MAX = 2048;
print "content-type: text/html\n\n";
binmode(STDIN);
@inx = <STDIN>;
splice(@inx,0,4);
splice(@inx,$#inx,1);
$in = join("",@inx);
$in = substr($in,0,length($in) - 2);;
open (ff,"<SAVE.txt");
@list = <ff>;
open(ff,">SAVE.txt");
binmode(ff);
print ff $in;
print ff (@list);
close(ff);
print "DONE, Uploaded Size: ".length($in)." bytes";
Many big thanks,
naitsabes
Last edited by naitsabes85; Jan 28th, 2005 at 11:18 AM.
-
Jan 28th, 2005, 09:54 AM
#2
Re: Need some help with "Upload.pl".
1) print ff $in, "\n";
2) huh? First 5 letters of what?
-
Jan 28th, 2005, 09:57 AM
#3
Thread Starter
Addicted Member
Re: Need some help with "Upload.pl".
Thanks
5 first letters of "@inx",
naitsabes
-
Jan 28th, 2005, 10:02 AM
#4
Re: Need some help with "Upload.pl".
You can use that substr command to get the first 5 characters o something
my $var = substr($inx[0],0,5);
substr is the function name. the first part inside the parenthesis is the data/variable you want to get a substring out of. The next is the starting index. In this case 0 which sets the cursor before the 1st character. Then the 5 tells it to get the next 5 characters.
You can then use the $var variable to name the file
-
Jan 28th, 2005, 11:18 AM
#5
Thread Starter
Addicted Member
Re: Need some help with "Upload.pl".
Thanks Cander for all your help!
naitsabes
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|