如何在取消上传时识别文件字符串
How to identify the file string when upload is cancelled?
我有一个网络编程问题需要处理,如下所示:
"您正在将表单元素传递给startImageUpload()
函数,并尝试将其作为字符串存储在添加到imagef1_cancel element
的HTML中。这是行不通的。您需要为每个表单提供一个unique id
,并使用此字符串来标识需要取消的上传。
目前,单击取消按钮时,它无法识别要从行中删除的文件。以下是var_dump($GET)
和print($imagecancelsql)
显示的内容:
注意:未定义的索引:/xxx/Mobile_app/cancelimage.php 第 22 行中的 imagecancelnamearray(0( { } 从图像中删除,其中图像文件 = '图像文件/'
那么如何对问题进行梳理,以便识别需要取消的上传的文件字符串呢?
以下是我目前尝试解决此问题的尝试:
var sourceImageForm;
function startImageUpload(imageuploadform, imagecancelname){
$(imageuploadform).find('.imagef1_upload_process').css('visibility','visible');
$(imageuploadform).find('.imagef1_cancel').css('visibility','visible');
$(imageuploadform).find('.imagef1_upload_form').css('visibility','hidden');
sourceImageForm = imageuploadform;
/*The above would show and hide elements within the form the file is being uploaded.
For example if I have three forms and the second form is uploading a file, then it
shows and hides the elements within the second form only */
$(imageuploadform).find('.imagef1_cancel').html('<div><button type="button" class="imageCancel" id="image_cancel_' + imagecancelname + '">Cancel</button></div>').find(".imageCancel").on("click", function(event) {
$.ajax("cancelimage.php?imagecancelname=" + $(this).attr('id').slice(13));
});
return true;
}
以下是表单代码:
var $fileImage = $("<form action='imageupload.php' method='post' enctype='multipart/form-data' target='upload_target' onsubmit='return startImageUpload(this);' class='imageuploadform' >" +
"Image File: <input name='fileImage' type='file' class='fileImage' /></label><br/><br/><label class='imagelbl'>" +
"<input type='submit' name='submitImageBtn' class='sbtnimage' value='Upload' /></label>" +
"</p><p class='imagef1_cancel' align='center'></p>" +
"<iframe class='upload_target' name='upload_target' src='#' style='width:0;height:0;border:0px;solid;#fff;'></iframe></form>");
最后下面是取消图像.php假设删除包含文件名的数据库行:
<?php
// ... connected to DB
$image_cancel = '';
if (isset($_GET["imagecancelname"])) { $image_cancel = $_GET["imagecancelname"]; }
$image_cancel = $_GET["imagecancelname"];
$imagecancelsql = "
DELETE FROM Image
WHERE ImageFile = 'ImageFiles/".mysql_real_escape_string($image_cancel)."'
";
print $imagecancelsql;
mysql_close();
?>
Notice: Undefined index: imagecancelname
在检查此 GET 索引是否存在时,您可以删除此通知:
$image_cancel = '';
if (isset($_GET["imagecancelname"])) { $image_cancel = $_GET["imagecancelname"]; }
// This line is only asking what that underscore is good for (typo?)
// $image_cancel_ = $_GET["imagecancelname"];
^
|
? ? ?
稍后,如果 $image_cancel 设置为有用的内容并且允许 (!((永远不要相信用户输入并进行正确的验证(,您应该继续。
相关文章:
- 让 WebStorm 识别后端和前端 JavaScript 文件
- 快速.JS无法识别所需的js文件的功能
- HTML 无法识别我要求它运行的 javascript 文件,语法错误:意外的令牌“<”(匿名函数)script.js:
- Javascript无法识别两个不同的PDF文件
- 代码完成无法识别OpenLayers js文件中的成员
- 无法识别一个 js 文件中的变量
- 我怎样才能让 Vim 简单地将 .md 文件识别为 Javascript
- 在设置 IIS Express 以识别 JSON 文件类型后 - VS 是否可以调用除纯文本之外的更好的编辑器
- 无法识别打字稿定义文件
- WordPress内置函数无法在ajax php文件上识别
- 如何识别加载的一个js文件
- 在浏览器中打开时,如何识别文件的独特之处
- 骨干.js:将视图、集合、模型分离到不同的js文件中,它们无法相互识别
- 如何在取消上传时识别文件字符串
- 如何使 IDE 识别出我在 HTML 文件中包含 jquery
- 页面无法识别外部 js 文件
- 命令失败: gm 识别: 无法打开文件 (2) [没有这样的文件或目录].通用模块和 ES6 承诺的问题
- 使用Node.js识别文件系统根
- stats.isFile()不能从路径中识别文件
- nodejs:识别文件克隆