【发布时间】:2012-04-23 17:48:09
【问题描述】:
我有一个包含文件输入的表单:
var $fileImage = $("<form action='imageupload.php' method='post' enctype='multipart/form-data' target='upload_target' onsubmit='startImageUpload(this);' class='imageuploadform' ><label>" +
"Image File: <input name='fileImage' type='file' class='fileImage' /></label><br/><label class='imagelbl'>" +
"<input type='submit' name='submitImageBtn' class='sbtn' value='Upload' /></label>" + +
"</p> <iframe class='upload_target' name='upload_target' src='#' style='wclassth:0;height:0;border:0px;solclass #fff;'></iframe></form>");
这链接到上传文件的 php 脚本:
<?php
$destination_path = str_replace("//", "/", $_SERVER['DOCUMENT_ROOT']."/")."ImageFiles";
$result = 0;
$target_path = $destination_path . basename( $_FILES['fileImage']['name']);
if(move_uploaded_file($_FILES['fileImage']['tmp_name'], $target_path)) {
$result = 1;
}
sleep(1);
?>
<script language="javascript" type="text/javascript">window.top.window.stopImageUpload(<?php echo $result; ?>);</script>
问题是,在 php 脚本中,它表明我有一个未定义的索引,无论它在 php 脚本中声明“fileImage”。但是我不知道为什么当我在“fileImage”形式的名称属性中提到时,它说我有未定义的索引。为什么它说我在 php 脚本中有一个未定义的“fileImage”索引?
这是一个应用程序的链接,您可以在其中附加包含文件输入的行,您可以对此进行测试并自行查看,但目前它一直说在上传过程中出现错误。 application
【问题讨论】:
-
试试 print_r($_FILES) 看看这个数组到底长什么样。
-
@h00ligan 我会这样做并回复你
-
当我执行 print_r($_FILES) 时,它带有一个奇怪的空白数组,即使我已经上传了一个文件。输出:
Array ( ) -
顺便说一句,您的 iframe 样式因在 'id' 上查找并替换为 'class' 而搞砸了... ;)
-
@RyanP 你在 iframe 代码中说将类更改为 id?
标签: php javascript html undefined-index