#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    25
    Rep Power
    0

    Uploading multiple images using paths all in same .txt file?


    Hi,

    I'm wondering if anybody knows if there is a way that multiple images can be uploaded as one text field (with the path to each image listed as below):

    | being the divider between file names

    C:\docs\pics\image1.jpg | Cther docs\other pics\image2.gif

    I'm currently running an upload script that does this for text, and was wondering if it was possible to do the same thing with images or mix the two.

    Basically.. is it possible to up-load a file within a file??

    If the original perl script will help explain myself better then I'll post it.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2003
    Posts
    778
    Rep Power
    16
    Hi,
    Perhaps you should post the script. Since you talk of uploads it would seem taht you are running perl as CGI and thus it's a bit hard to understand how it can access files on the client machine.

    --
    http://ww.raditha.com/megaupload/
    Perl File Upload Progress monitor.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    25
    Rep Power
    0
    Ok, this form is shown using the first script (upload1.pl)

    <form ENCTYPE="multipart/form-data" method="post" action="<!--GLOBAL::script_dir_url-->/upload2.pl">
    <input type="file" name="UploadedFile" size="40" CLASS="forms">
    <input type="submit" value="Upload" class="buttons">

    and this sends to the following script:

    ##################################################################################

    #!/usr/bin/perl

    use DBI;
    use IO::Socket;
    use Mod qw(%form $couser $copass $db $dbh %config);
    use strict;
    require "variables/variables.cgi";

    my ($buffer,$bound,@parts,$filename,@subparts,@stuff,$totalT,$fname,@a,$extension,$directory,$mailerror );

    read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
    $buffer =~ /^(.+)\r\n/;
    $bound = $1;
    @parts = split(/$bound/,$buffer);

    $filename=$parts[1];
    $parts[1] =~ s/\r\nContent\-Disposition.+\r\n//g;
    $parts[1] =~ s/Content\-Type.+\r\n//g;
    $parts[1] =~ s/^\r\n//;

    @subparts = split(/\r\n/,$parts[2]);
    $directory = $subparts[3];
    $directory =~ s/\r//g;
    $directory =~ s/\n//g; #got the directory name

    $filename =~ s/Content-Disposition\: form-data\; name=UploadedFile\; filename\=//g;
    @stuff=split(/\r/,$filename);
    $filename = $stuff[1];
    $filename =~ s/\"//g;
    $filename =~ s/\r//g;
    $filename =~ s/\n//g;

    @a=split(/\\/,$filename);
    $totalT = @a;
    --$totalT;
    $fname=$a[$totalT];

    @a=split(/\//,$fname);
    $totalT = @a;
    --$totalT;
    $fname=$a[$totalT];

    @a=split(/\:/,$fname);
    $totalT = @a;
    --$totalT;
    $fname=$a[$totalT];

    @a=split(/\"/,$fname);
    $filename=$a[0];

    my $header = &Mod::header;
    &Mod::Display($header);

    if($parts[1] !~ m/[\w\d]/) {Mod::oooops("The file which you want to upload is invalid or empty.");}

    $extension = (split(/\./,$filename))[-1];

    if ($extension !~ /(txt)/i ) {Mod::oooops("The file you want to upload is not the correct type. The file must end with .txt .");}

    my ($one,$two,$three,$four,$five,$six,$seven,$eight,$nine,$ten);
    my $na = "N/A";
    my @newdata = split(/\n/, $parts[1]);
    my $cool = split(/\n/, $parts[1]);
    my ($newdata,$theline,$type,@items,$display);

    foreach $newdata (@newdata) {
    ($one,$two,$three,$four,$five,$six,$seven,$eight,$nine,$ten)=split(/\|/, $newdata);
    $theline++;

    ##################################################################################

    then my insert in to DB and display screen for each line found within the txt file.

    Now, parts $seven, $eight, $nine and $ten are the images.. at the moment I work them as URLs to other images, but want to allow my users to upload picutres off their hard drives, so need to grab the above file parts and upoad them individually.

    Any help will be great.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    25
    Rep Power
    0
    Ok, I now realise that these files have got to be defined as a FILE form input type.
    Is there anyway to get Perl to define these $variables I have as FILE types within this script or will I have to generate a form for each row of data and make the user submit it (or find a javascript to automatically submit the form for me??)

    Any help will be much appreciated.. I'm baning my head against a brick wall here

IMN logo majestic logo threadwatch logo seochat tools logo