0
파일을 FTP 서버에 업로드하려고합니다. 디렉토리가 chmode 777이어야한다는 if 문에 잡히지 만 ftp의 모든 디렉토리를 수동으로 chmode 77하고 코드에 함수를 추가해야합니다.PHP를 사용하여 FTP로 파일 업로드 - 서버에 쓰지 않습니다.
두 번째로 업로드 프로세스가 시작되면 .tmp 파일이 만들어 지는지 묻습니다. FTP에 업로드 되었습니까? 그렇다면 .mp3 파일과 함께 .tmp 파일에 대한 액세스도 허용해야합니까? 나는 그 과정에서 그들의 사용이 실제로 무엇인지 모르고있어 누군가가 그것을 설명하는 데 시간을 할애하면 도움이 될 것입니다.
몇 가지 변수 내용 : 사전에 어떤 도움
$ftp_server="***********";
$ftp_user_name="************";
$ftp_user_pass="***********";
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
if(ftp_login($conn_id, $ftp_user_name, $ftp_user_pass)){
// Configuration - Your Options
$allowed_filetypes = array('.mp3','.tmp'); // These will be the types of file that will pass the validation.
$max_filesize = 2097152; // Maximum filesize in BYTES (currently 2MB).
$cutName = substr($_SESSION['dir'], 0, -1);
$upload_path = "htdocs/site/telemessages/en/". $_SESSION['dir'];
echo "upload path: ".$upload_path; // The place the files will be uploaded to (currently a 'files' directory).
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); // Get the extension from the filename.
// Check if the filetype is allowed, if not DIE and inform the user.
if(!in_array($ext,$allowed_filetypes))
die('The file you attempted to upload is not allowed.');
// Now check the filesize, if it is too large then DIE and inform the user.
if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize)
die('The file you attempted to upload is too large.');
// Check if we can upload to the specified path, if not DIE and inform the user.
if(!is_writable($upload_path))
die('You cannot upload to the specified directory, please CHMOD it to 777.');
// We'll start handling the upload in the next step
echo"FORCE: ".$_FILES['userfile']['tmp_name'];
//Upload the file to your specified path.
$result = move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename);
if(!$result)
{
return -1;
}
else
{
echo $result;
//SET PROPER READ PERMISSIONS
$result2 = chmod($upload_path, 0777);
echo "Result: ".$result2;
}
}else{
echo "login failed";
}
감사 : 여기
$upload_path = /htdocs/site2/telemessages/en/Apologies
$_FILES['userfile']['tmp_name'] = /tmp/phpwkfxrW
내가 FTP로 파일을 전달하는 데 사용하고 코드입니다.
$ upload_path = "htdocs/site/telemessages/en /". $ _SESSION [ 'dir']; - 이것이 "/"를 선도해야합니까? –