Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php JQuery上传不';无法使用重写的url处理页面_Php_Jquery_Ajax_Mod Rewrite - Fatal编程技术网

Php JQuery上传不';无法使用重写的url处理页面

Php JQuery上传不';无法使用重写的url处理页面,php,jquery,ajax,mod-rewrite,Php,Jquery,Ajax,Mod Rewrite,我发现了一个带有进度条的php jquery上传脚本,它实际上可以工作 问题是,如果我使用ApacheModRewrite将url从重写到,它将不起作用,但如果我使用未写入的url,它将起作用 jquery不会在重写的url上运行有什么原因吗 它不使用jquery表单来ajax上传,而只是执行普通上传 这是upload.php的代码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.o

我发现了一个带有进度条的php jquery上传脚本,它实际上可以工作

问题是,如果我使用ApacheModRewrite将url从重写到,它将不起作用,但如果我使用未写入的url,它将起作用

jquery不会在重写的url上运行有什么原因吗

它不使用jquery表单来ajax上传,而只是执行普通上传

这是upload.php的代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Ajax Upload and Resize with jQuery and PHP</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/jquery.form.js"></script>
 <script> 
        $(document).ready(function() { 
        //elements
        var progressbox     = $('#progressbox');
        var progressbar     = $('#progressbar');
        var statustxt       = $('#statustxt');
        var submitbutton    = $("#SubmitButton");
        var myform          = $("#UploadForm");
        var output          = $("#output");
        var completed       = '0%';

                $(myform).ajaxForm({
                    beforeSend: function() { //brfore sending form
                        submitbutton.attr('disabled', ''); // disable upload button
                        statustxt.empty();
                        progressbox.slideDown(); //show progressbar
                        progressbar.width(completed); //initial value 0% of progressbar
                        statustxt.html(completed); //set status text
                        statustxt.css('color','#000'); //initial color of status text
                    },
                    uploadProgress: function(event, position, total, percentComplete) { //on progress
                        progressbar.width(percentComplete + '%') //update progressbar percent complete
                        statustxt.html(percentComplete + '%'); //update status text
                        if(percentComplete>50)
                            {
                                statustxt.css('color','#fff'); //change status text to white after 50%
                            }
                        },
                    complete: function(response) { // on complete
                        output.html(response.responseText); //update element with received data
                        myform.resetForm();  // reset form
                        submitbutton.removeAttr('disabled'); //enable submit button
                        progressbox.slideUp(); // hide progressbar
                    }
            });
        }); 

    </script> 
 <link href="style/style.css" rel="stylesheet" type="text/css" />
</head>
<body>

<form action="processupload.php" method="post" enctype="multipart/form-data" id="UploadForm">
<table width="500" border="0">
  <tr>
    <td>File : </td>
    <td><input name="ImageFile" type="file" /></td>
  </tr>

  <tr>
    <td>&nbsp;</td>
    <td><input type="submit"  id="SubmitButton" value="Upload" /></td>
  </tr>
</table>
</form>

<div id="progressbox"><div id="progressbar"></div ><div id="statustxt">0%</div ></div>
<div id="output"></div>


</body>
</html>

我猜想罪魁祸首可能是缺少目标页面(《代码》)操作指向的页面

它可能在
uploads/processupload.php
(使用重写时)和
processupload.php
中查找它


您可能忘了重写
processupload.php
,但在您发布
.htaccess
文件之前,我无法确定。我猜罪魁祸首可能是缺少目标页面(操作所指向的页面)

它可能在
uploads/processupload.php
(使用重写时)和
processupload.php
中查找它


你可能忘了重写
processupload.php
,但在你发布
.htaccess
文件之前,我无法确定。jquery不使用ajax发送数据的问题是什么?如果我不重写url,但将upload.php改为uploads/upload.php会导致失败,那就好了。你能回答我的问题吗,那“失败”是怎么回事外观?表单不做任何事情,或页面重写?检查javascript控制台以从服务器获取标题和答案。jQuery应该完全不知道服务器端的内容。它发送请求并接收响应。另一方面,这可能是另一个错误-重写的URL可能不会被重写,而是重定向,告诉我们您
.htaccess
。jquery不使用ajax发送数据的问题?如果我不重写url,但将upload.php更改为uploads/upload.php会导致失败,那么效果很好。你能回答我的问题吗,为什么会“失败”外观?表单不做任何事情,或页面重写?检查javascript控制台以从服务器获取标题和答案。jQuery应该完全不知道服务器端的内容。它发送请求并接收响应。另一方面,这可能是另一个错误-重写的URL可能不会被重写,而是重定向,告诉我们您
.ht访问
。如果这不起作用,您应该检查文件上载时发出的请求。我更喜欢Firebug(有一个“网络”选项卡,您可以在其中看到此类请求),但Chrome和Opera都内置了类似的工具。如果这不起作用,您可能应该检查文件上载时发出的请求。我更喜欢Firebug(有一个“网络”选项卡,您可以在其中看到此类请求),但Chrome和Opera都内置了类似的工具。
Options +FollowSymLinks
Options +Indexes
RewriteEngine on
RewriteBase /

RewriteRule ^admin$ admin/ [R,L]

# Admin rewrite rules
RewriteRule ^/?admin/$ admin/index.php [NC,L]
RewriteRule ^/?admin/news$ /admin/news.php [NC,L]
RewriteRule ^/?admin/uploads/upload$ /admin/upload.php [NC,L]