2017-11-05 2 views
0

PHP가 업로드 된 파일을 전혀 처리하지 못하는 것 같습니다. 내 현재 코드는 다음과 같습니다PHP가 파일을 업로드하지 않음

<?php 
error_reporting(E_ALL); 
ini_set('display_errors', 1); 
?> 


<html> 
    <body> 
     <form action="" method="POST" enctype="multipart/form-data"> 
      <input type="file" name="image"> 
      <input type="submit"> 
     </form> 
     <p>Sent file: <?php echo $_FILES['image']['name']; ?></p><br> 
     <p>File size: <?php echo $_FILES['image']['size']; ?></p><br> 
     <p>File type: <?php echo $_FILES['image']['type']; ?></p><br> 
     <?php print_r($_FILES); ?> 
    </body> 
</html> 

내 php.ini의 파일 : 내가 얻을

;;;;;;;;;;;;;;;; 
; File Uploads ; 
;;;;;;;;;;;;;;;; 

; Whether to allow HTTP file uploads. 
; http://php.net/file-uploads 
file_uploads = On 

; Temporary directory for HTTP uploaded files (will use system 
default if not 
; specified). 
; http://php.net/upload-tmp-dir 
;upload_tmp_dir = 

; Maximum allowed size for uploaded files. 
; http://php.net/upload-max-filesize 
upload_max_filesize = 10000M 

; Maximum number of files that can be uploaded via a single request 
max_file_uploads = 20 

및 litterally 아무것도 업로드시

:

Sent file: 
Notice: Undefined index: image in 
/var/www/upload.php on line 13 
File size: 
Notice: Undefined index: image in 
/var/www/upload.php on line 14 
File type: 
Notice: Undefined index: image in 
/var/www/upload.php on line 15 
Array() 

가 가장 가능성이 눈부시게 분명하지만, 내 삶에 대해 나는 잘못하고있는 것을 발견하지 못한다.

답변

0

양식 제출을 처리하고 더 구체적으로 파일을 저장하려면 작업 (PHP 파일)을 지정해야합니다.

See examples and documentation at http://php.net/manual/en/features.file-upload.post-method.php

또한, 웹 서버에서 원하는 업로드 디렉토리에 대한 사용 권한을 확인하십시오. 램프 환경에서 아파치 사용자와 www 데이터 그룹은 폴더를 소유하고 그것에 대한 쓰기 권한을 가져야한다.

+0

PS- 발생하는 오류는 파일을 업로드하기 전에 웹 페이지를로드 할 때 파일 객체 정보를 가져 오기 시도입니다. 동일한 PHP 파일을 사용하여 Webform을 렌더링하고 처리하려면 $ _FILES가 설정된 경우 파일 정보 만 인쇄하는 조건을 추가하십시오. –

+0

작업 필드를 비워두면 현재 페이지로 게시물 데이터가 전송되므로 페이지가 게시물 데이터가 있다고 가정하고 양식에서 정보를 처리해야합니다. 나는 페이지를 처음로드 할 때 오류가 발생할 것으로 예상한다. 파일을 선택하고 제출을 클릭하면 나에게 당황 스럽다. 오류가 발생하면 페이지를 다시로드하여 게시물 데이터를 사용할 수 있어야한다고 가정한다. – kaioker2

관련 문제