0
我正在尝试为我的数据库中的记录创建更新表单。这是形式:
<form id="form_update_ad" method="post" action="inc/API.php" enctype="multipart/form-data">
<input type="text" name="input_publisher" id="input_publisher_edt" placeholder="Name" />
<input type="text" name="input_link" id="input_link_edt" placeholder="Link" />
<input type="file" name="file2Upload_edt" id="file2Upload_edt" />
<input type="submit" value="" id="btnUpdate" />
<input type="hidden" name="command" value="update_ad" />
<input type="hidden" value="" id="curr_image_filename" />
<input type="hidden" value="" id="curr_add_id" />
</form>
所有输入字段的值(除“文件”)设置与jQuery,而且都设置正确,我仔细检查了。
然后,我有一次我打提交按钮正在执行这个jQuery函数:
$("#form_update_ad").on("submit", function(event){
event.preventDefault();
// some validations...
if(errors.length==0)
{
$(this).off("submit");
this.submit();
}
else
{
// if there are errors - do something here
}
});
我想在API.php文件做的是:检查是否有新的图像文件将被否则 - 将new_image_filename设置为当前文件名(从curr_image_filename
隐藏的输入字段中请求它),如果是 - 从服务器上删除当前设置的文件,上传新映像,将new_image_filename设置为其名称并更新数据库。在mypath中\ API.php curr_image_filename第21行,这是这样的::所以我写了这个代码:
$newImageFileName = "";
if($_FILES["file2Upload_edt"]["name"]=='')
{
$newImageFileName = $_REQUEST["curr_image_filename"];
}
else
{
if(delete_file_from_server($_REQUEST["curr_image_filename"]))
{
$newImageFileName = saveImage2Server("file2Upload_edt");
update_ad($_REQUEST["curr_ad_id"],$_REQUEST["input_publisher"], $newImageFileName, $_REQUEST["input_link"]);
}
}
但我不断收到此错误信息:未定义指数$newImageFileName = $_REQUEST["curr_image_filename"];
为什么会发生我该如何解决它?
谢谢!我不再有'未定义的索引'消息! A也注意到我将调用放置到'update_ad()'函数的另一个问题(如果没有新文件要上传,代码不会到达它),所以我改变了它。现在我遇到了一些与我的PDO更新查询有关的问题,将不得不查看它。再次感谢您的帮助! – Igal