0
서버에서 이미지를 업로드하고 검색하려고합니다.
나는 무언가를했지만 문제는 이미지가 업로드되지 않는다는 것입니다. 내 스크립트는 파일 이름 만 가져오고 이미지는 서버 폴더에 저장됩니다. 이 스크립트는 다른 데이터 만 저장하지만 이미지는 저장하지 않습니다. 실수는 어디 있는지 모르겠지만 사용했던 경로는 corret입니다. 또한 이미지를 검색하여 프런트 엔드에 게시해야합니다.이미지 업로드 및 검색 서버 WORDPRESS
<div class="wrap">
<form method="POST">
Date: <input type="text" name="class_date"> <br>
Event: <input type="text" name="class_name"><br>
<input type="hidden" value="class_sched" name="posttitle"><br>
<input type="hidden" name="size" value="350000">
Image:<input type="file" name="class_image"><br>
<input type="submit" value="submit" name="submit">
</form>
</div>
<?php
global $wpdb;
if(isset($_POST['submit']))
{
$target = plugins_url("/images",__FILE__);
$target = $target . basename($_FILES['class_image']['name']);
$class_date = $_POST['class_date'];
$class_name = $_POST['class_name'];
$class_image = ($_FILES['class_image']['name']);
$wpdb->insert('wp_calendar', array('class_name'=> $class_name, 'class_date'=>$class_date, 'class_image'=>$class_image));
//Writes the photo to the server
if(move_uploaded_file($_FILES['class_image']['tmp_name'], $target))
{
//Tells you if its all ok
echo "The file ". basename($_FILES['class_image']['name']). " has been uploaded, and your information has been added to the directory";
}
else
{
//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}
}
이미지를 쓰려고하는 폴더는 777 쓰기 권한이 있습니까? (ftp에서는 filezilla와 같은 프로그램을 통해 이것을 확인할 수 있습니다) – NoobishPro
기본적으로 업로드되었지만 이미지가 디렉토리에 없습니다. – user3627265