【发布时间】:2015-05-14 05:17:06
【问题描述】:
我想从本地上传文件到服务器。我尝试了以下代码,但它给出了一些错误。请帮我解决
<?php
$server="115.120.147.261";
$ftp_user_name="root";
$ftp_user_pass="3424dd";
$dest="/home/root/web/Price-War/";
$source="/home/root/sample.txt";
$connection = ftp_connect($server);
if($connection)
{
echo "Connection Established";
}
$login = ftp_login($connection, $ftp_user_name, $ftp_user_pass);
if (!$connection || !$login) { die('Connection attempt failed!'); }
$upload = ftp_put($connection, $dest, $source, FTP_ASCII);
if (!$upload) { echo 'FTP upload failed!'; }
ftp_close($connection);
?>
它抛出以下错误。
Connection Established
PHP Warning: ftp_put(): Could not create file. in /home/root/Desktop/upload.php on line 16
【问题讨论】:
-
检查您的文件夹权限是否已设置为 777?
-
我已授予文件权限。但我仍然遇到同样的错误。
标签: php file-upload upload ftp