简体   繁体   English

将文件上传到另一个域 - 到目标的属性文件不正确

[英]Upload files to another domain - Incorrect property files to destination

Using a form + PHP upload files in a folder This works fine.在文件夹中使用表单 + PHP 上传文件 这工作正常。

Those same files, I have to replicate in another domain.那些相同的文件,我必须复制到另一个域中。 The upload is via FTP with this piece of code:使用这段代码通过 FTP 上传:

 define("FTP_ADDRESS","DESTINY_SERVER");
 define("FTP_USERNAME","MY_FTP_USER");
 define("FTP_PASSWORD","PASSWORD_FTP");

 $LOCAL_FILE = $_FILES["files"]["tmp_name"][0];
 $FTP_FILE = "LA_RUTA_DE_DESTINO";

 $conn = ftp_connect(FTP_ADDRESS);
 $login = ftp_login($conn, FTP_USERNAME, FTP_PASSWORD);
 ftp_put($conn, $FTP_FILE, $LOCAL_FILE, FTP_ASCII);
 ftp_close($conn);  

This uploading files to another domain works PERFECTLY.这将文件上传到另一个域非常有效。

The problem is that in another domain, the target domain, if I run a modification on the files uploaded gives me permission issues.问题是,在另一个域中,目标域中,如果我对上传的文件进行修改,则会出现权限问题。

Uploads files via POST forms has as property the APACHE user.通过 POST 表单上传文件的属性是 APACHE 用户。 But these, uploaded through FTP with PHP function, MY_FTP_USER have as owner, so then I can do nothing with them using PHP and should be able to manipulate them using a php CMS但是这些,通过带有 PHP 功能的 FTP 上传,MY_FTP_USER 作为所有者,所以我不能使用 PHP 对它们做任何事情,并且应该能够使用 php CMS 操作它们

What can I do to make the files are uploaded to a FTP, and then from PHP can manipulate them without problem?我该怎么做才能使文件上传到 FTP,然后从 PHP 可以毫无问题地操作它们?

There are issues of CHMOD permissions are user property issues.有CHMOD权限问题是用户属性问题。

You can change file permission level of file after file upload after upload.您可以在上传文件后更改文件的文件权限级别。 Put your php user in same group with APACHE user and;将您的 php 用户与 APACHE 用户放在同一组中;

$conn = ftp_connect(FTP_ADDRESS);
 $login = ftp_login($conn, FTP_USERNAME, FTP_PASSWORD);
 ftp_put($conn, $FTP_FILE, $LOCAL_FILE, FTP_ASCII);

 // Change permission
 if (ftp_chmod($conn, 0664, $FTP_FILE) !== false) {
    echo "$file chmoded successfully to 0664\n";
 } else {
    echo "Could not chmod $file\n";
 }
 ftp_close($conn); 

664 => group users can modify files 664 => 组用户可以修改文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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