简体   繁体   中英

How to upload file using PHP on Synology NAS / FTP Server?

I want to make a file and upload that on Synology NAS using PHP. Our NAS, it's support FTP so i tried to use ftp_put() from here and tried to use curl() from here . But i still cannot upload the file to NAS. Both of that code is running well and doesn't show the message error.

Here's the destination path on our Synology NAS : /DMS/upload-file/

And here's my simple code using ftp_put():

$ftp_path = '/DMS/upload-file/'.$_FILES["uploadedfile"]["name"];
$conn_id = ftp_ssl_connect($host,$port);
$login_result = ftp_login ( $conn_id , $username , $password );
$upload = ftp_put($conn_id, $ftp_path, $_FILES["uploadedfile"]["tmp_name"], FTP_ASCII);
print (!$upload) ? $bgalert.'There was a problem while uploading '.$ftp_path.'</p>' : $bgalert.'Upload complete</p>';
ftp_close($conn_id); 

The result always

There was a problem while uploading /DMS/upload-file/filename.jpg

Can anyone help me how to fix our problem ? I really need your help. Thank you.

您可以检查此文件夹的权限/ DMS / upload-file /吗?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM