업로드 한 파일을 옮기는 데 문제가 있습니다. 업로드가 오류없이보고 된 것 같습니다. 업로드 할 폴더에 777이 있습니다. 시스템은 워드 프레스이고 내가 뭘 잘못하고 있는지 전혀 모른다.업로드 된 파일을 PHP로 이동
양식은 다른 양식 안에 있음을 유의해야합니다. 최종 결과는 사용자가 두 번째 양식을 제출하기 전에 이미지 자르기 및 태그, 제목 설명 등을 추가 할 수있는 이미지 업로드 (이 양식은 큰 이미지 안에 있음)를 갖는 것입니다. 두 번째 양식의 최종 제출은 맞춤형 게시물 유형에 게시되며 정상적으로 작동합니다. 그냥 움직이는 파일과 jcrop 내가 걱정입니다.
아무도 오타를 볼 수 있습니까?
할 수 없습니다.
move_uploaded_file($_FILES["file"]["tmp_name"], $_FILES["file"]["name"]);
당신은과 같이, 두 번째 매개 변수에 업로드 된 디렉토리를 지정해야합니다 :
<form method="POST" action="" enctype="multipart/form-data">
<label for="image_upload">Image Upload</label>
<input id="image_upload" type="file" class="text_input" value="" name="file">
<input id="image-upload" type="submit" class="button" value="Upload" name="upload">
<!-- <img id="image-upload" src="<?php echo get_template_directory_uri(); ?>/images/sago.jpg" alt=""> -->
<?php
// Process the upload
if (!empty ($_POST['upload'])) {
$allowedExts = array("gif", "jpeg", "jpg", "png");
$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/pjpeg")
|| ($_FILES["file"]["type"] == "image/x-png")
|| ($_FILES["file"]["type"] == "image/png"))
&& ($_FILES["file"]["size"] < 100000)
&& in_array($extension, $allowedExts))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
}
else
{
echo "<div> Upload: " . $_FILES["file"]["name"] . "<br>";
echo "Type: " . $_FILES["file"]["type"] . "<br>";
echo "Size: " . ($_FILES["file"]["size"]/1024) . " kB<br>";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br> </div>";
//set temp dir path
$path = $_SERVER['DOCUMENT_ROOT'];
$upload_dir = $path . '/wp-content/uploads/jcrop_temp/';
if (file_exists($path . '/wp-content/uploads/jcrop_temp/' . $_FILES["file"]["name"]))
{
echo "<div style='border: solid 1px #BF5738; color: #BF5738; padding: 1em;'> The File: <span style='color: black;'>" . $_FILES["file"]["name"] . "</span> already exists. Please rename the file before trying again. </div>";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"], $_FILES["file"]["name"]);
echo "Stored in: " . $upload_dir . $_FILES["file"]["name"];
echo "<div style='border:solid 1px #E1E1E1; max-width: 710px; text-align: center;'>
<img id='image-upload' src='" . "/wp-content/uploads/jcrop_temp/" . $_FILES["file"]["name"] . "'>
</div>
";
}
}
}
else
{
echo "Invalid file";
}
//end upolad if
}
?>
</form>
얼마나 큰 파일은? –
25k, 한계를 넘지 않음, 나는 이미 테스트를 위해 어이없는 100000에 부합했다. – vincentieo