Codeigniter上的上传路径返回“上传路径似乎无效” [英] Upload path on Codeigniter returns "the upload path doesn't seem to be valid"

查看:95
本文介绍了Codeigniter上的上传路径返回“上传路径似乎无效”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我已经尝试了大部分的修复,我已经阅读,他们大多数提到关于APPPATH,base_url(),真正的路径等,但我真的不知道为什么他们都没有工作,对我有用的是,我使用的实际路径,而不是一个url,但是一个与C:\xampp \htdocs .. blah blah blah ..现在我已经读取一个线程的url和目录aren' t同样的东西..和upload_path只接受目录路径,我的意思是uploads文件夹在服务器上的实际位置不是URL ..现在我的问题是如何来APPPATH不工作。作为我知道它的实际目录路径。但是当我试图显示它是只返回../applicaiton/真正是在$ config ['upload_path']上使用upload.php最好的路径,特别是当它部署到一个实际的服务器,它是真的很讨厌找到你的上传文件夹的目录路径注意不使用initialize()方法我把我的配置config / upload.php

Now i've tried most of the fixes that i've read, most of them mention about APPPATH, base_url(), real path and etc. but i really don't know why all of them didn't work, what worked for me is that i've used the actual path, not a url but the one with the C:\xampp\htdocs.. blah blah blah.. now i've read one thread that url and directory aren't the same thing.. and the upload_path accepts only directory path and i mean the actual location of the uploads folder on the server not the URL.. now my question is how come APPPATH don't work. as what i know it the actual directory path. but when i tried to display is it return only "../applicaiton/" what really is the best path to be used on the $config['upload_path'] on the upload.php specially when deploying it to an actual server it is really a nuisance finding the directory path of your upload folder, NOTE im not using the initialize() method i'm putting my configs on config/upload.php

EDITS:

我有一个单独的文件... upload.php

i have this on a separate file... upload.php

<?php 
$config['upload_path'] ='./uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '5000';
$config['max_width'] = '1600';
$config['max_height'] = '1200';

这是我的控制器

     if($this->upload->do_upload('image'))
     {
         //Did something here
     }
     else
     {
        //Did something for errors like display_errors()
     }

并且最终结果是显示上传路径似乎无效
,我也尝试过这些代码行

and end result is it displays "the upload path doesn't seem to be valid" and i've tried these line of code also

试用1:

$config['upload_path'] ='./uploads/';

试用2:

$config['upload_path'] ='uploads/';

试用3:

$config['upload_path'] ='/admin/assets/uploads/';

试用4:

$config['upload_path'] ='./admin/assets/uploads/';

试用5:

$config['upload_path'] ='admin/assets/uploads/';

唯一的工作原理是

 $config['upload_path'] ='C:\xampp\htdocs\practice\admin.abcgencon\admin\assets\uploads'';

并且使用最后一部分作为路径是有点乱,所以我也试过 APPPATH 但它不工作也显示../application..

and using the last part as a path is kinda messy so i've tried also APPPATHbut it doesn't work also it also display "../application"..

作为@cryptic说发布此代码段。

as @cryptic said i've posted this code snippet.

推荐答案

问题,你尝试了 realpath code> APPPATH 单独?

Question, you tried realpath and APPPATH seperately?

在Codeigniter APPPATH 文件夹

In Codeigniter APPPATH points to the application folder

示例 :(将文件夹放在应用程序文件夹之外,只是说如果没有这样做)

Example: (place your folder outside the application folder, just saying if you did not do that way) lets say te folder where we want to place the files called images

所以你需要做的是组合 realpath()和 APPPATH

So what you need to do is combine realpath() and APPPATH

$image_path = realpath(APPPATH . '../images');

并传递到您的config

and pass it to your config

$config['upload_path'] = $image_path;

这篇关于Codeigniter上的上传路径返回“上传路径似乎无效”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆