다음 코드를 사용하여 이미지 경로를 데이터베이스에 저장합니다.데이터베이스에 이미지 경로 저장
파일 경로가 데이터베이스에 저장되지 않습니다. 이미지 이름은?
왜 이런 생각입니까?
<?php
session_start();
error_reporting(E_ERROR | E_PARSE);
// escape variables for security
$ImageName = mysqli_real_escape_string($con, $_POST['imageName']);
//getting the filename of the image file.
$file_name = $_FILES['fileToUpload']['name'];
$sql="UPDATE images SET imageLoc = '$file_name', imageName = '$ImageName'
WHERE Username = '".$_SESSION["Username"]."'";
//$query = mysqli_query($con,$sql);
if (!mysqli_query($con,$sql)){
echo "error";
}
echo "yess";
mysqli_close($con);
?>
데이터베이스 연결에 문제가 없습니다.
감사
XHTML 부 :
Select image to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload Image" name="submit">
Name of Image: <input type="text" name="imageName"/>
$ _FILES [ 'fileToUpload'] [ 'name']; 파일 이름 만 있으면 저장하는 경로를 정의해야합니다. – pathfinder
저장 대상은 무엇입니까? 'enctype = "multipart/form-data"'를 가지고 있습니까? – mainstreetmark
게시물과 함께 모든 양식 태그 등이 있습니다. C : filename.jpg와 같은 파일 경로 이름을 데이터베이스에 저장하려고합니다. – usercoder