Php 找不到源文件。请检查您的路径
我尝试使用codeigniter ftp类上传文件Php 找不到源文件。请检查您的路径,php,codeigniter,ftp,Php,Codeigniter,Ftp,我尝试使用codeigniter ftp类上传文件 $this->load->library('ftp'); $config['hostname'] = 'www.domain.com'; $config['username'] = 'xxxxxxxxx'; $config['password'] = 'xxxxxxxx'; $config['port'] = 21; $config['passive'] = FALSE;
$this->load->library('ftp');
$config['hostname'] = 'www.domain.com';
$config['username'] = 'xxxxxxxxx';
$config['password'] = 'xxxxxxxx';
$config['port'] = 21;
$config['passive'] = FALSE;
$config['debug'] = TRUE;
$this->ftp->connect($config);
$this->ftp->upload('C:\Users\SYSTEM2\Desktop\checking\ash.jpg\' , base_url().'uploads/myfolder/ash.jpg/');
$this->ftp->close();
但是显示出这个错误
“找不到源文件。请检查路径。”
请任何人帮我解决这个问题…而不是这个问题
$this->ftp->upload('C:\Users\SYSTEM2\Desktop\checking\ash.jpg\' , base_url().'uploads/myfolder/ash.jpg/');
使用
但是您应该知道ftp服务器中的根路径,有时它是“/www/yourdomen/”尝试
$this->ftp->upload('C:/Users/SYSTEM2/Desktop/checking/ash.jpg',“/www/uploads/myfolder/”)
这对我来说很好,祝你好运Codeigniter ftp类先检查文件是否存在,然后执行上载。你可以查看Codeigniter文件夹system\libraries\ftp.php第238行中的代码
if ( ! file_exists($locpath))
{
$this->_error('ftp_no_source_file');
return FALSE;
}
根据站点的要求,如果您在web服务器外部使用文件,则本地文件路径的格式应为//computername/share/filename
这意味着您必须将文件放在具有公共权限的共享文件夹中
如果设置正确,并确保权限允许网络用户访问该文件,则该文件可能会正常工作
我建议使用表单而不是手动编写文件路径,然后您可以编写代码,如:
$file=$_FILES["userfile"]["name"];
$this->ftp->upload($file , './upload','ascii', 0775);
我很惊讶你没有遇到语法错误。$fname='C:\\Users\\SYSTEM2\\Desktop\\checking\\ash.jpg';如果(file_exists($fname)){$this->ftp->upload($fname),/www/public/myfolder/ash.jpg');}否则{echo'file not found!';}输出:-“file not found!”,错误始终是源文件(如明确所述),不知道为什么每个人都在建议新的目的地路径可能是因为你在windows中写入了不正确的ash.jpg路径?尝试单击文件ash.jpg,选择“属性”并查看“位置”参数“C:\Users\SYSTEM2\Desktop\checking”我得到了这个OK。我得到了它。但您应该知道什么是远程服务器(对您的本地路径和PC一无所知)。解决方案是像现在这样组织本地web服务器,并在本地计算机上使用脚本,或在PC上公开必须从internet上看到的内容。第二个更复杂的问题是源文件的位置。当我检查文件_存在时('C:/Users/SYSTEM2/Desktop/checking/ash.jpg')。它返回false。你能告诉我我的源文件有什么问题吗。我确信我的电脑中存在该文件。那么为什么它会说“找不到源文件”。确保ash.jpg存在于C:/Users/SYSTEM2/Desktop/checking/otherwise中,它将返回false。
$file=$_FILES["userfile"]["name"];
$this->ftp->upload($file , './upload','ascii', 0775);