2015-01-11 5 views
0

좋아, 지난 2 일 동안 Google을 사용했는데 내 코드에 문제가 없었습니다. 처음에는 잘못된 경로를 사용하는 것 같았지 만1에서 "Hilfe Center"(도움 센터 등)는 올바른 경로가되어야한다고 말했습니다. "e : \ Kunden \ Homepages \ 11 \ d12345678 \ www \ UploadTest 당신이 파일PHP로 파일을 업로드하는 중에 오류가 발생했습니다.

$max_filesize = 524288; // Maximum filesize in BYTES (currently 0.5MB). 
    $upload_path = "e:\\Kunden\\Homepages\\11\\d12345678\\www\\UploadTest"; 


    $filename = $_FILES['userfile']['name']; // Get the name of the file (including file extension). 


    if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize) 
     die('The file you attempted to upload is too large.'); // if we upload large file then we get error. 
    if(!is_writable($upload_path)) 
     die('You cannot upload to the specified directory, please CHMOD it to 777.'); // if we have no enough permission then got error. 

    if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename)){ 
        // if everything is fine then we upload file and go to somewhere else 
     header ('location: whereeveryouwantogo.php'); 
    } else { 
     echo 'There was an error during the file upload. Please try again.'; 
    } 
을 업로드 사이트에

<form action=\"upload.php\" method=\"post\" enctype=\"multipart/form-data\"> 
       <input type=\"file\" name=\"datei\"><br> 
       <input style=\"position:absolute;left:5px\" type=\"submit\" value=\"Hochladen\"> 
       </form> 

: " 그래서 난 다음 코드를 사용하고 (분명히 내가 축복하는은 phpinfo()를 가지고 당신의 경로에 적응해야한다)

PHP 스크립트가 실행되는 사이트 (upload.php)에 있습니다. 다른 스레드에서 코드를 얻었고 문제 해결을 위해이 코드를 사용하려고했습니다. 나중에 나는 내 자신의 코드로 돌아갈 것이다.

나는 마지막 오류에 지금입니다 :

'파일 업로드 중 오류가 발생했습니다. 다시 시도하십시오. ';

뉴스 기반 사이트에서 나중에 사용되는 .txt 파일 만 업로드하려고합니다. 사전에 어떤 도움을 Thx!

+3

어떻게하면 $ {$ upload_path}의 결과가 될 것이라고 생각하십니까? $ filename'? –

+0

"e : \ Kunden \ Homepages \ 11 \ d12345678 \ www \ UploadTest" – user3528269

+0

그래서 -'$ filename'은 어디에 있습니까? '$ upload_path' 만 출력했습니다 –

답변

0

문제는 파일 변수의 이름이나 이름의 이름이라고 생각합니다. $ files = $ _ FILES [ 'datei'] [ 'tmp_name'];

관련 문제