Results 1 to 5 of 5

Thread: Need some help with "Upload.pl".[Solved]

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2004
    Location
    sweden
    Posts
    176

    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.

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913

    Re: Need some help with "Upload.pl".

    1) print ff $in, "\n";

    2) huh? First 5 letters of what?
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Apr 2004
    Location
    sweden
    Posts
    176

    Re: Need some help with "Upload.pl".

    Thanks
    5 first letters of "@inx",
    naitsabes

  4. #4
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913

    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
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Apr 2004
    Location
    sweden
    Posts
    176

    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
  •  



Click Here to Expand Forum to Full Width