Fellow monks,
I'm back again to ask for your wisdom.
I posted a question,
here, about a file upload script. That question was refering to syntax errors, these errors were solved thanks to
Jeurd and
a few others. Although the syntax is okay, it seems the script isn't.
When I tried to upload some images files(JPEG) all I got were a few text files with the local path to the image in it(i.e. the path to the image on the comp of the person who tried to upload it). Although the slashes were gone the C:windowsmydocuments....... etc etc was still there. I quite stumped at the moment.
I seached around and didn't find any similar probs and I've had a good hard look at the script but I can't see anything wrong(although this is my firist upload script.)
If you find anything wrong please leave a reply. All help is greatly aprieciated.
Thanks in advance.
I'm going back to try find the problem again.
The codes inside
All the Best, Eoin...
If everything seems to be going well, you obviously don't know what the hell is going on.
#!/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
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.