Php 上传codeigniter htaccess只是不工作
我创建了完全相同的副本,我甚至更改了$this->upload->do\u uploadname\u文件的输入; 我两个都试过了Php 上传codeigniter htaccess只是不工作,php,.htaccess,codeigniter,upload,Php,.htaccess,Codeigniter,Upload,我创建了完全相同的副本,我甚至更改了$this->upload->do\u uploadname\u文件的输入; 我两个都试过了 ./data/ ./application/data/ 由于我的文件夹要上传,CHMOD 0777,仍然无法上传。 我启动了FF和FireBug以查看我从本地主机发送/获取的标题,我认为问题可能存在于.htaccess文件中,但没有那么确定。。。 我处理子文件夹localhost/something/orhttp://192.168.0.101/sms/ 我的ro
./data/
./application/data/
由于我的文件夹要上传,CHMOD 0777,仍然无法上传。
我启动了FF和FireBug以查看我从本地主机发送/获取的标题,我认为问题可能存在于.htaccess文件中,但没有那么确定。。。
我处理子文件夹localhost/something/orhttp://192.168.0.101/sms/
我的routes.php应该很好,除了上传脚本,没有404或任何其他问题
另一件奇怪的事是我必须这样做
<?=form_open_multipart("/sms/upload/do_upload")?>
如果我创建这样的表单
<?=form_open_multipart("/upload/do_upload")?>
显然http://192.168.0.101/upload 我的本地主机上不存在我的整个安装在子文件夹/sms下/
我的.htaccess
<IfModule mod_rewrite.c>
# mod_rewrite rules
RewriteEngine on
# The RewriteBase of the system (if you are using this sytem in a sub-folder).
RewriteBase /sms/
# This will make the site only accessible without the "www."
# (which will keep the subdomain-sensive config file happy)
# If you want the site to be accessed WITH the "www."
# comment-out the following two lines.
RewriteCond %{HTTP_HOST} !^192.168.0.101$ [NC]
RewriteRule ^(.*)$ http://192.168.0.101/$1 [L,R=301]
# If a controler can't be found - then issue a 404 error from PHP
# Error messages (via the "error" plugin)
# ErrorDocument 403 /index.php/403/
# ErrorDocument 404 /index.php/404/
# ErrorDocument 500 /index.php/500/
# Deny any people (or bots) from the following sites: (to stop spam comments)
# RewriteCond %{HTTP_REFERER} nienschanz\.ru [NC,OR]
# RewriteCond %{HTTP_REFERER} porn\.com
# RewriteRule .* - [F]
# Note: if you are having trouble from a certain URL just
# add it above to forbide all visitors from that site.
# You can also uncomment this if you know the IP:
# Deny from 192.168.1.1
# If the file is NOT the index.php file
RewriteCond %{REQUEST_FILENAME} !index.php
# Hide all PHP files so none can be accessed by HTTP
RewriteRule (.*)\.php$ index.php/$1
# If the file/dir is NOT real go to index
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>
# If Mod_ewrite is NOT installed go to index.php
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
#<ifModule mod_expires.c>
# <filesmatch "\.(ico|flv|jpg|jpeg|png|gif|js|css|swf)$">
# ExpiresActive on
# ExpiresDefault "access plus 1 year"
# </filesmatch>
#</ifModule>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/xhtml text/html text/plain text/xml
text/javascript application/x-javascript text/css
</IfModule>
FileTag none
新信息:
似乎在点击上传按钮后,它被重定向到某个附加了数据的地方,从某个地方它被重定向到我的实际上传脚本,该脚本在没有附加数据的情况下完成所有工作,因此我认为这是.htaccess的问题。
CI抛出此错误
您没有选择要上载的文件
这是我上面链接的CI指南的副本为什么不使用相对链接?删除初始斜杠“/” 您为上载文件创建了目标文件夹并更改了权限 尝试删除重写基/sms/ 如果希望url相同,请在apache配置文件中更改documentRoot 希望这能帮助你。如果没有,请从代码中添加更多内容。最后: 问题出在相对/绝对路径中,或者实际上是我的CodeIgniter设置中,在我的config.php中有一行
$config['base_url'] = 'http://localhost/sms/';
这很好,但是在我的.htaccess文件中,没有提到本地主机有IP
整个问题通过在配置文件和.htaccess文件中放置相同的路径来解决这个问题与.htaccess无关好吧,但是问题在哪里呢我甚至使用分析器查看帖子数据,但它总是空的。与修改过的网站的相对链接很难实现,因为一个用户可能在中有任意数量的子目录。我在我的一生中都使用相对链接创建网站,我看不到任何问题,不像,在服务器之间传输站点变得非常有用-更详细,那么您如何在example.com/users/view/username/profile/edit/页面中放置相对链接?当它与example.com/users/view/username/comment/add/页面相同时,我不明白,为什么要创建指向相同内容的两个URL?并且,假设您在example.com/users/view/username/profile/edit/页面中,并且希望创建指向example.com/users/view/username/comment/add/I的链接,我只需输入href=../../comment/addRelative links:codeigniter本身创建绝对链接。文件夹:已创建并放置在0777上
HTTP/1.1 301 Moved Permanently
Date: Tue, 28 Aug 2012 01:52:43 GMT
Server: Apache/2.4.2 (Win32) OpenSSL/1.0.1c PHP/5.4.4
Location: http://192.168.0.101/upload/do_upload
<IfModule mod_rewrite.c>
# mod_rewrite rules
RewriteEngine on
# The RewriteBase of the system (if you are using this sytem in a sub-folder).
RewriteBase /sms/
# This will make the site only accessible without the "www."
# (which will keep the subdomain-sensive config file happy)
# If you want the site to be accessed WITH the "www."
# comment-out the following two lines.
RewriteCond %{HTTP_HOST} !^192.168.0.101$ [NC]
RewriteRule ^(.*)$ http://192.168.0.101/$1 [L,R=301]
# If a controler can't be found - then issue a 404 error from PHP
# Error messages (via the "error" plugin)
# ErrorDocument 403 /index.php/403/
# ErrorDocument 404 /index.php/404/
# ErrorDocument 500 /index.php/500/
# Deny any people (or bots) from the following sites: (to stop spam comments)
# RewriteCond %{HTTP_REFERER} nienschanz\.ru [NC,OR]
# RewriteCond %{HTTP_REFERER} porn\.com
# RewriteRule .* - [F]
# Note: if you are having trouble from a certain URL just
# add it above to forbide all visitors from that site.
# You can also uncomment this if you know the IP:
# Deny from 192.168.1.1
# If the file is NOT the index.php file
RewriteCond %{REQUEST_FILENAME} !index.php
# Hide all PHP files so none can be accessed by HTTP
RewriteRule (.*)\.php$ index.php/$1
# If the file/dir is NOT real go to index
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>
# If Mod_ewrite is NOT installed go to index.php
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
#<ifModule mod_expires.c>
# <filesmatch "\.(ico|flv|jpg|jpeg|png|gif|js|css|swf)$">
# ExpiresActive on
# ExpiresDefault "access plus 1 year"
# </filesmatch>
#</ifModule>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/xhtml text/html text/plain text/xml
text/javascript application/x-javascript text/css
</IfModule>
FileTag none
<?php
class Upload extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url'));
}
function index()
{
$this->load->view('upload_form', array('error' => ' ' ));
}
function do_upload()
{
$config['upload_path'] = './data/';
//$config['allowed_types'] = 'gif|jpg|png';
//$config['max_size'] = '100';
//$config['max_width'] = '1024';
//$config['max_height'] = '768';
//$config['file_name'] = $_FILES['userfile']['name'];
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload("userfile"))
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->load->view('upload_success', $data);
}
}
}
?>
$config['base_url'] = 'http://localhost/sms/';