NAS에 많은 파일이 저장되어 있습니다. NAS는 네트워크 드라이브로 서버에 연결되어 있습니다 (예 : Y : //에 있음).HTTP를 통해 서버에 연결된 NAS에서 파일 다운로드
저는 xampp을 사용하여 PHP로 작성된 응용 프로그램을 제공합니다. 이 응용 프로그램은 ftp 대신 http를 통해 직접 NAS에서 파일을 다운로드 할 수 있도록 제작되었습니다.
NAS에서 파일을 설정할 수 있으므로 http URL (예 : example.com/files/the-file.zip)을 사용하여 다운로드 할 수 있습니까?
은 XAMPP는 C에 있습니다 : // 디렉토리
참고하십시오 XAMPP의 htdocs에 이미 도메인 액세스로 변경됩니다. 당신은 아마 (
<?php
$downloadFolder = 'Y:/';
$fileName = $downloadFolder . $_GET['file'];
$sanitizedFileName = realpath($fileName);
if($fileName !== $sanitizedFileName) {
throw new RuntimeException('Someone tried to escape');
}
// As seen in http://php.net/readfile:
if (file_exists($fileName)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($fileName).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($fileName));
readfile($fileName);
exit;
}
또는 htaccess로를 통해 모든 것을 실행할 수있는 방법을 찾아야하지만, 그 처리의 보안을 통해 당신에게 덜 제어 할 수 있습니다 그래서 당신은 PHP를 통해 이렇게 시도 할 수 도메인 포인팅 문제
[XAMPP 및 WordPress를 실행하는 서버 IP에 대한 포인팅 도메인 이름] 가능한 복제본 (https://stackoverflow.com/questions/24845562/pointing-domain-name) -to-server-ip-running-xampp-and-wordpress) –
아니요, 다른 경우라고 생각합니다. –