2014-09-12 1 views
0

다음 코드에 오류가있어서 파일을 서버에 업로드 할 수 없습니다. 누군가 두 파일을 살펴보고 잘못된 정보를 얻을 수 있는지 조언 해 주시겠습니까? 나는 두꺼운 정보를 알고 있지만 도움이 될 것입니다.php 및 html 양식을 통해 파일을 업로드하는 코드에 오류가 발생했습니다.

파일이 작은 내부 인트라넷에 있으므로 데이터베이스 연결과 암호를 파일에 넣고 있다는 사실에 신경 쓰지 않습니다.

내가 마지막 미안한 오류 만 받고 MySQL 데이터베이스로 전달되는 정보가 없기 때문에 도움이된다면 크게 도움이 될 것입니다. 업로드 없이는 제대로 작동하도록 양식과 코드를 얻을 수 있지만 함께 사용할 수는 없습니다. 업로드 디렉토리 및 액세스 권한을 확인했는데 모두 정상입니다.

HTML 양식 :

<form enctype="multipart/form-data" action="add.php" method="POST"> 
Model:<br /> <input type="text" name="model"><br> 
Size:<br /> <input type="text" name="size"><br> 
Total width:<br /> <input type="text" name="tot_width"><br> 
Internal width:<br /> <input type="text" name="int_width"><br> 
Total height:<br /> <input type="text" name="tot_height"><br> 
Frame height:<br /> <input type="text" name="fra_height"><br> 
Total depth:<br /> <input type="text" name="tot_depth"><br> 
Seat height:<br /> <input type="text" name="sea_height"><br> 
Seat depth:<br /> <input type="text" name="sea_depth"><br> 
Arm height:<br /> <input type="text" name="arm_height"><br> 
Std leg height:<br /> <input type="text" name="std_leg_height"><br> 
Image:<br /> <input type="file" name="image"><br> 
<input type="submit" value="Add"> 
</form> 

PHP의 :

//This is the directory where images will be saved 
$target = "/images/product"; 
$target = $target . basename($_FILES['image']['name']); 

//Get all the other information from the form 
$model=$_POST['model']; 
$size=$_POST['size']; 
$totWidth=$_POST['tot_width']; 
$intWidth=$_POST['int_width']; 
$totHeight=$_POST['tot_height']; 
$fraHeight=$_POST['fra_height']; 
$totDepth=$_POST['tot_depth']; 
$seaHeight=$_POST['sea_height']; 
$seaDepth=$_POST['sea_depth']; 
$armHeight=$_POST['arm_height']; 
$stdLegHeight=$_POST['std_leg_height']; 
$pic=($_FILES['image']['name']); 

// Connect to Database 
mysql_connect("localhost", "databaseUser", "databasePassword") or die(mysql_error()) ; 
mysql_select_db("databaseName") or die(mysql_error()) ; 

//Write information to the database 
mysql_query("INSERT INTO `prod_dims` VALUES '$model', '$size', '$totWidth', '$intWidth', '$totHeight', '$fraHeight', '$totDepth', '$seaHeight', '$seaDepth', '$armHeight', '$stdLegHeight', '$pic'") ; 

//Put the image on the server 
if(move_uploaded_file($_FILES['image']['name'], $target)) 
{ 

//Is the upload ok 
echo "The file ". basename($_FILES['uploadedfile']['name']). " has been uploaded, and  your information has been added to the directory"; 
} 
else { 

//Give an error if its not 
echo "Sorry, there was a problem uploading your file."; 
} 

답변

0

변화

if(move_uploaded_file($_FILES['image']['name'], $target)) 

if(move_uploaded_file($_FILES["image"]["tmp_name"], $target)) 
+0

큰 물건. 언제나 당신이 뭔가를 응시하고 뻔한 오류를 뚫어지게 바라 보면 실망합니다 :) – Yeti

+0

도움을 주신 것에 대해 많은 감사드립니다. Ram : – Yeti

+0

도움이되었는데 다행 이네요. –

관련 문제