Hey all,

I've recently had quite a few problems with this cgi upload script, as you can see here and finnaly when i'm sure I have it figured I get one last stumpper!!

I've looked into the docs for CGI.pm but I couldn't find a solution to my problem. After a bit of pondering i'v discovered that the script will work(or a least I hope so) from a *nix run because they use / as there directory structure dividers but windows use \ and the way my script works it seems to interpolate the whole file name string taken in by the %pics.

So what should be " C:\WINDOWS\Profiles\eoin\My Documents\images\border.jpg" Acctualy becomes "C:WINDOWSProfilesoinMy Documentsimageorder.jpg"

Before I get a chance to stip the filepath from the filename. And obviously the stripping process won't work anymore because there is nothing to strip from. (I.e no \). Is there anyway to fix this without changing alot of the script.


Thanks for any help in advance.

The codes inside
#!/usr/bin/perl -w use strict; use warnings; use diagnostics; use CGI; my %pics; my @pic_filehandles; my @filelist; my $key; my @files; my $upload_dir; my $q = CGI->new; my $user = $q->param("user"); my $album = $q->param("T1"); unless ( -d "./albums/$album" ) { mkdir( "./albums/$album", 0775 ); $upload_dir = "./albums/$album"; } { $pics{"pic$_"} = $q->param("photo$_") for 0..13; @pic_filehandles = map { $q->upload("photo$_") } '',0..13; } strip_filename(); sub strip_filename{ my @allkeys = sort(keys(%pics)); foreach $key (@allkeys) { $pics{$key} =~ s/.*[\/\\](.*)/$1/; } } my $cntr = 0; @files = sort(keys(%pics)); foreach $key (@files) { open IMAGE, ">$upload_dir/$pics{$key}"; binmode IMAGE; while (<$pic_filehandles[$cntr]>) { print IMAGE; } close IMAGE; $cntr += 1; } print $q->header ( ); print <<END_HTML; <HTML> <HEAD> <TITLE>Thanks!</TITLE> </HEAD> <META HTTP-EQUIV="refresh" CONTENT="05;URL=http://eoinmurphy00.netfirm +s.com/cgi-bin/main.cgi?status=home&user=$user"> <title>Please Wait</title><head>Thank you for uploading your Photos.<b +ody>Please Wait<br>You will be redirected to the main page in 2 secon +ds.<br>Thank You $user</body> </HTML> END_HTML

All the Best, Eoin...

If everything seems to be going well, you obviously don't know what the hell is going on.


In reply to Lost Backs\ash by eoin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.