uso questa sub per fare l'upload,ma se lo faccio da pc mi trasferisce il file con il nome C:\document etc...
come skippo il percorso??
codice:
sub do_upload {
my $submit = $q->param('submit') || undef;
if ($submit)
{
my $file = $q->param('UPLOAD') || die "Error: (do_upload) You did not select a file!!\n$!";
$file =~ m/^.*(\\|\/)(.*)/;
my $name;
$2 ? $name = $2 : $name = $file;
my $upload_path = $target_upload . 'MYSIMPLENEWS/upload/' . $name;
open(LOCAL, ">$upload_path") || die "Error: (do_upload) $upload_path\n$!";
binmode(LOCAL);
while(<$file>) {
print LOCAL $_;
}
close(LOCAL);
chmod (0644,"$upload_path");
print "Content-type: text/html","\n\n";
print qq~<html>L'immagine $name \è stata trasferita con successo!! (ora puoi chiudere questa finestra)</html>~;
} else {
print "Content-type: text/html","\n\n";
print qq~
<html>
<head>
<title>..:: MYSIMPLENEWS(1.9.3) ::..</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" TOPMARGIN="10" LEFTMARGIN="15">
<h2>Upload images:</h2>
<form ENCTYPE="multipart/form-data" ACTION="mysimplenews.cgi" METHOD="POST">
<input type="hidden" NAME="DO" VALUE="UPLOAD">
Please select a file to upload:
<input type="file" NAME="UPLOAD">
</p>
<input type="submit" NAME="submit" value=" submit image ">
</form>
</body>
</html>~;
}
}
Credevo che $file =~ m/^.*(\\|\/)(.*)/; facesse al caso mio,ma invece no