-2
파일을 디렉토리에 업로드하는 중 오류가 발생합니다. 다음은 오류입니다 : 과거 2 시간 동안 검색하는 동안 나는 온라인 내가 찾을 수 evrything을 시도알림 : 정의되지 않은 색인 : sPic (사진 업로드 시도 중)
<?php
$name = htmlspecialchars($_POST['sName']);
$ip = htmlspecialchars($_POST['sIp']);
$type = $_POST['sType'];
$port = htmlspecialchars($_POST['sPort']);
$website = htmlspecialchars($_POST['sWeb']);
$video = htmlspecialchars($_POST['sVideo']);
$pic = ($_FILES['sPic']['name']); // line 8
$desc = htmlspecialchars($_POST['sDesc']);
$target = "/uniqueminecraftservers/slist/banners/";
$target = $target . basename($_FILES['sPic']['name']); // line 13
// Connects to your Database
mysql_connect("localhost", "root", "") or die(mysql_error()) ;
mysql_select_db("slist") or die(mysql_error()) ;
//Writes the information to the database
mysql_query("INSERT INTO `postdata` VALUES ('$name', '$ip', '$port', '$type', '$website', '$video', '$desc')") ;
//Writes the photo to the server
if(move_uploaded_file($_FILES['sPic']['tmp_name'], $target)) // line 23
{
//Tells you if its all ok
echo "The file ". basename($_FILES['uploadedfile']['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.";
}
?>
:
Notice: Undefined index: sPic in C:\wamp\www\uniqueminecraftservers\upload\upload.php on line 8
Notice: Undefined index: sPic in C:\wamp\www\uniqueminecraftservers\upload\upload.php on line 13
Notice: Undefined index: sPic in C:\wamp\www\uniqueminecraftservers\upload\upload.php on line 23
가 여기 내 PHP입니다. 나는 이것을 고정하는 방법을 생각할 수 없다.
참고 : PHP이 질문은 폐쇄되기 전에 5.4.3
당신은 업로드 형태로 편집 할 수 있습니까? – Barmar
[mysql_ *'functions] (http://stackoverflow.com/q/12859942/1190388)을 새 코드로 사용하지 마십시오. 더 이상 유지 관리되지 않으며 [공식적으로 권장되지 않습니다] (https://wiki.php.net/rfc/mysql_deprecation). 빨간 상자 보이니? 대신 준비된 문에 대해 알아보고 [tag : PDO] 또는 [tag : MySQLi]를 사용하십시오. – hjpotter92
'$ _FILES [ 'sPic'] [ 'error']'는 무엇이라고 말합니까? '$ _FILES [ 'uploadedfile'] [ 'name']'은 어디서 온 것입니까? 왜 검사하지 않니? 그리고 'htmlspecialchars'는 데이터를 표시 할 때만 입력 데이터에 사용해서는 안됩니다. –