FTP 图片上传在 PHP 中无法正常工作
FTP image upload doesn't work properly in PHP
我有一个连接到网站的网络应用程序。我的 Web 应用程序在 Ubuntu 服务器 (LAMP) 中运行。在我的网络应用程序中,有一个名为添加新客户端的功能。添加新客户端时,用户必须为客户端设置图像。当用户单击保存按钮时,图像应上传到 Linux 服务器本身,我将图像发送到我的 共享托管服务器 ,该网站使用 FTP。 这在我的 windows 本地主机(我使用的是 wamp 服务器) 中非常有效。但是当我将我的 Web 应用程序放到 Ubuntu 服务器时,FTP 图片上传 有时有效 而 有时无效 .
这是我的代码
private $config_ftp = array('hostname'=>'xxxx.com','username'=>'xxx@xxxxx.com','password'=>'xxxxx','passive'=>FALSE,'debug'=>FALSE,'port'=>21);
$source_original = $this->img_path['img_original'] . $file_name;
$destination_original = $this->full_file_path['img_original'] . $file_name;
if($this->ftp->upload($source_original,"./assets".$destination_original)) {
$this->response['msg']="Images Uploaded successfully!";
$this->response['status']=true;
}
当我在上传后检查目标文件夹时,它看起来像这样。文件大小为 0kb。有时它会正确上传。我不得不再次提到这个过程在 windows localhost.
中完全正常
谢谢。
$this->ftp->需要显示 upload() 代码才能找到实际问题。
因为如果 $image_size = $_FILES['image']['size'];
$image_size 为 0,则您的图像有问题,否则您可以通过 move_uploaded_file($_FILES['image']['tmp_name'], "YOUR-UPLOAD-FOLDER/YOUR-IMAGE-NAME-PLUS-EXTENSION");
成功上传。
类似问题:
问题出在我的ftp_config。
我必须做的是将 passive 和 debug 设置为 true
private $config_ftp = array('hostname'=>'xxxx.com','username'=>'xxx@xxxxx.com','password'=>'xxxxx','passive'=>TRUE,'debug'=>TRUE ,'port'=>21);
我有一个连接到网站的网络应用程序。我的 Web 应用程序在 Ubuntu 服务器 (LAMP) 中运行。在我的网络应用程序中,有一个名为添加新客户端的功能。添加新客户端时,用户必须为客户端设置图像。当用户单击保存按钮时,图像应上传到 Linux 服务器本身,我将图像发送到我的 共享托管服务器 ,该网站使用 FTP。 这在我的 windows 本地主机(我使用的是 wamp 服务器) 中非常有效。但是当我将我的 Web 应用程序放到 Ubuntu 服务器时,FTP 图片上传 有时有效 而 有时无效 .
这是我的代码
private $config_ftp = array('hostname'=>'xxxx.com','username'=>'xxx@xxxxx.com','password'=>'xxxxx','passive'=>FALSE,'debug'=>FALSE,'port'=>21);
$source_original = $this->img_path['img_original'] . $file_name;
$destination_original = $this->full_file_path['img_original'] . $file_name;
if($this->ftp->upload($source_original,"./assets".$destination_original)) {
$this->response['msg']="Images Uploaded successfully!";
$this->response['status']=true;
}
当我在上传后检查目标文件夹时,它看起来像这样。文件大小为 0kb。有时它会正确上传。我不得不再次提到这个过程在 windows localhost.
中完全正常谢谢。
$this->ftp->需要显示 upload() 代码才能找到实际问题。
因为如果 $image_size = $_FILES['image']['size'];
$image_size 为 0,则您的图像有问题,否则您可以通过 move_uploaded_file($_FILES['image']['tmp_name'], "YOUR-UPLOAD-FOLDER/YOUR-IMAGE-NAME-PLUS-EXTENSION");
成功上传。
类似问题:
问题出在我的ftp_config。
我必须做的是将 passive 和 debug 设置为 true
private $config_ftp = array('hostname'=>'xxxx.com','username'=>'xxx@xxxxx.com','password'=>'xxxxx','passive'=>TRUE,'debug'=>TRUE ,'port'=>21);