-1
我有perl cgi脚本,我有上传文件的窗体。 一切工作正常,但我有一些控制(检查我的SQL表)用户选择文件后,如果具有相同名称的文件已经存在。 如果存在,我打印javascript确认询问用户是否要替换旧文件。 而我不知道如何将文件句柄传递给脚本。我upload.pl代码:perl cgi传递文件句柄
my $query = new CGI;
my $file = $query->param("file");
my $confirm = $query->param("confirm");
my $name = $query->param("name");
if(!$confirm){
SQL check
if(SQL check){
print "Content-type: text/html\n\n";
print "<form action=\"upload.pl\" method=post name=\"upload.pl\">
<input type=\"hidden\" name=\"file\" value=\"$file\">
<input type=\"hidden\" name=\"confirm\" value=\"true\">
<input type=\"hidden\" name=\"name\" value=\"$name\">
</form>
<form action=\"index.pl\" method=GET name=\"index.pl\">
<input type=\"hidden\" name=\"login\" value=\"$login\">
<input type=\"hidden\" name=\"token\" value=\"$token\">
</form>
<script>
var answer = confirm(\"WARNING .....\");
if (answer==true){
document.forms[\"upload.pl\"].submit();
}
else{
document.forms[\"index.pl\"].submit();
}
</script>
";
exit;
}
}
所以用户后确认,他想要替换的文件我第一次提交表单,然后再次运行upload.pl但是当我尝试
my $upload_filehandle = $query->upload("file");
它没有返回。
有没有办法通过文件句柄? 还是没有javascript确认和其他提交脚本的其他方式?
感谢您的任何建议。