2013-08-24 3 views
0

안녕하세요, 일부 웹 예제 다음 이미지를로드하는 폼을 만들려고하지만로드 할 이미지를 가져올 수 없습니다. 아파치를 실행중인 개인 페도라 박스에서 일하고 있습니다. 아파치와 다른 설정이 필요합니까? 여기에 업로드 이미지해야 내 양식 스크립트입니다 :html form enctype = multipart/form-data

  <form name ="input" enctype="multipart/form-data" action = "addPhotograph.php" method = "get"> 
      <table> 
       <tr> 
        <th>Title:</th> <td><input type="text" name ="photoname"></td> 
       </tr> 
       <tr> 
       <th>Photograph:</th> <td><input type="file" id="file" name="file" accept="image/*"></td> 
       </tr> 
       <tr> 
       <th>Photographer:</th><td><input type="" name="photographer"></td> 
       </tr> 
       <tr> 
       <th>Genre:</th><td><input type = "" name="genre"></td> 
       </tr> 
      <table> 
       <input type="submit" value = "Submit"> 
      </form> 

을 그리고 여기 내 PHP 스크립트입니다 :

 <?php 
     $uploaddir = '/var/www/html/photodb'; 
     $uploadfile = $uploaddir . basename($_FILES['file']['name']); 

     echo '<pre>'; 
     if (move_uploaded_file($_FILES['file']['name'], $uploadfile)) { 
      echo "File is valid, and was successfully uploaded.\n"; 
     } else { 
      echo "Possible file upload attack!\n"; 
     } 

     echo 'Here is some more debugging info:'; 
     print_r($_FILES); 

     print "</pre>"; 
     ?> 

나는 양식을 통해 이미지를 추가하면 PHP는 양식은 "파일 업로드 공격의 가능성이 말하는 실패! " 파일을 옮기지 못했거나 파일을 업로드하지 못했다는 의미입니까?

저는 대학 과제를 위해 어떤 반응이나 다른 생각을하고 있습니다. :)

+0

'$ uploaddir = '/ var/www/html/photodb /'; '을 시도해보십시오. 보안을 강화해야하지만 아무것도 업로드하지 않으셔도됩니다. –

답변

3
는 POST에 방법을 변경

: 당신은 GET 방식을 통해 파일을 게시 할 수 없습니다

<form name ="input" enctype="multipart/form-data" action = "addPhotograph.php" method = "post"> 

.

+0

내 방법이 게시물을 지불한다고 생각합니다. – codeBarer

+0

POST로 변경하면 경로가 올바르게 정의되고 쓰기가 가능하면 작동합니다. –

+0

고마워요! 그것은 분명히 지금 무언가를하고 있습니다. 시도하고 업로드 할 때 다음과 같은 메시지가 나타납니다 : 가능한 파일 업로드 공격! 은 디버깅 정보입니다 : 배열 ( [파일] => 배열 ( [이름] => Biner-Wallpaper.jpg [형태] => 이미지/JPEG [tmp_name] =>/TMP/phpDhnhmZ [오류] => 0 [크기] => 369791 ) – codeBarer

0

양식 게시를 사용하지 않는 이유는 무엇입니까?

<form name ="input" enctype="multipart/form-data" action = "addPhotograph.php" method = "post"> 
관련 문제