drwghu6386 2012-05-07 00:15
浏览 44

如何将图像名称作为参数传递?

There is something I am trying to acheive but I don't quite understand how to do it. What I think I need to do is to pass the name of the image as a parameter to the cancelimage.php script and the use that in the query. But I don't think I am doing this with var image_file_name. What do I need to do to achieve this?

Below is the startImageUpload() function where it starts uploading an image and where the cancel button exist:

 function startImageUpload(imageuploadform){

    ...

                $(".imageCancel").on("click", function(event) {

var image_file_name = $(this).attr('image_file_name');

                jQuery.ajax("cancelimage.php"  + image_file_name)
                    .done(function(data) {

                    $(".imagemsg" + _cancelimagecounter).html(data);
                });

                return stopImageUpload();

            });       
                  return true;
            }

Below is the cancelimage,php page where it is suppose to delete a row from the database?

<?php

$username="xxx";
$password="xxx";
$database="xxx";

mysql_connect('localhost',$username,$password);

mysql_select_db($database) or die( "Unable to select database");

$image_file_name = $_GET["fileImage"]["name"];

    echo "File Upload was Canceled";

        $imagecancelsql = "DELETE FROM Image 
        WHERE ImageFile = 'ImageFiles/". mysql_real_escape_string($image_file_name)."'";

    mysql_query($imagecancelsql);

    mysql_close();


?>
  • 写回答

1条回答 默认 最新

  • dongzongzi0379 2012-05-07 00:24
    关注

    If that is the issue with only variable passed with "image_file_name", then why dont your try to achieve it like this:

    var image_file_name = "<?php echo $image_file_name; ?>"
    

    Then you can just forward it as url to ajax call like in regular mannar:

           jQuery.ajax("cancelimage.php"  + image_file_name)
                        .done(function(data) {
                       .....some code here....
    
        });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么