한 명의 사용자 (사이트 관리자 및 소유자)가 자신의 사진을 사이트의 갤러리에 업로드 할 수있는 사이트를 만들고 있습니다. 사진을 업로드해도 문제는 없지만 디렉토리로 옮기려고하면 오류가 발생합니다. ecowebhosting.co.uk의 cpanel에 대한 모든 권한을 허용하는 등 많은 것을 시도했습니다. 하지만 내 스크립트는 그룹 권한없이 어쨌든 업로드 할 수 있어야합니다. 여기 내 PHP 스크립트입니다 :PHP move_uploaded_file 서버 오류
$target_dir = "/assets/collages/";
$target_file = $target_dir.basename($_FILES['image']['name']);
$uploadOk = 1;
$imageFileType = pathinfo($target_file, PATHINFO_EXTENSION);
$upload_dir = $_SERVER['DOCUMENT_ROOT'] . "assets/collages/";
if (is_dir($upload_dir)) {
// do upload logic here
} else {
echo 'Upload directory is not writable, or does not exist.';
}
if(isset($_POST["submit"])) {
$check = getimagesize($_FILES["image"]["tmp_name"]);
if($check !== false) {
$uploadOk = 1;
} else {
echo "File is not an image.<br>";
$uploadOk = 0;
}
if (file_exists($target_file)) {
echo "Sorry, file already exists.<br>";
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.<br>";
// if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES["image"]["name"], $target_file)) {
echo "The file ". basename($_FILES["image"]["name"]). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.<br>";
}
}
}
그리고 여기 내 양식 (사용하여 부트 스트랩)입니다 :
<form method="post" enctype="multipart/form-data">
<div class="row">
<div class="col-md-2">
<div class="form-group">
<label for="year">Year</label>
<input type="text" name="year" id="year" placeholder="Year" class="form-control" />
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label for="title">Title</label>
<input type="text" name="title" id="title" placeholder="Title" class="form-control" />
</div>
</div>
</div>
<div class="form-group">
<label for="image">Image File</label>
<input name="image" type="file" id="image">
<p class="help-block">Chose the collage image you would like to add.</p>
</div>
<button type="submit" class="btn btn-success" name="submit">Submit</button>
</form>
그리고 마지막으로, 그것은 호스팅 패키지, 그래서 그 만들 것 나도 몰라 차이.
그리고 어떤 오류가 발생합니까? 웹 서버 로그에 액세스 할 수 있는지 확인하십시오 (어쩌면 공급자 제어판에서). –
@MarcCompte xxxxxxxxx.com xx.xxx.xx.x - - [07/Jun/2016 : 22 : 41 : 12 +0100] "http://xxxxxxxx.com/ftpriurNj.cgi를 구하십시오. HTTP/1.1"200 169 " - ""JustAnInstaller/0.1 "이것은 내 기록에있는 모든 것입니다. – Twonty2
CGI 파일에 대한 GET 호출에 대한 항목입니다. PHP 파일에 대한 POST 호출에 대해 뭔가가 있어야합니다. –