2015-01-24 1 views
1

그래서 새로운 업로드 서비스에서 테스트로 파일을 업로드하지 못하게하는 문제가 있습니다.HTML 양식은 PHP 스크립트에 일부 POST 변수를 보내지 않습니다.

모든 양식을 정확하게 기입하고 제출할 때마다 up-loader에 대해 vars 묶음이 설정되지 않습니다.

<form action="upload.php" method="post"> 
      <span style="color: green;">Select the file you want to upload:</span> 
      <input type="file" class="form-control" name="fileToUpload" id="fileToUpload" /> 
      <br>TIP: Taking a long time for the page to load after uploading? That's your browser uploading the files. It will take time if you have slow internet or you are uploading a big file. 
      <br><br> 
      <b><span style="color: red;">DISCLAIMER: I, Mark Jones, am not held responsible for the uploading of porn, pirated music, images and films. In the event that any pirated, offensive or sexual files are uploaded they will be deleted by staff or removed by storage clean-ups. Please keep all these types of files that are not permitted away from this website. Only upload things that are not sold elsewhere and keep porn on your own PC. Once you upload a file against this disclaimer after accepting it (You can't upload files without accepting it), The uploaded file becomes your responsibility. It will be deleted and if it is not deleted then you'll have to witness a punishment that hasn't been put into effect by me, but by others such as my hosting or the DMCA. I also would like all the members/users of this site not to upload Viruses, Tojans, Malware and Spyware. If you do, It will be deleted or other punishments will occur. Also by accepting this disclaimer you must use your real name in the box below.</span></b><br><br> 
      <!--<input type="submit" value="Upload Image" name="submit" />--> 
      <input type="radio" name="disclaimer" value="1">Accept</input> 
      <input type="radio" name="disclaimer" value="0" checked>Decline</input><br><br> 
      Insert your full real name below:<br> 
      <input type="text" class="form-control" name="realname" value="Full name"></input><br> 
      Do you want your own personal folder for your file?<br> 
      <input type="radio" name="pf" value="1">Yes</input> 
      <input type="radio" name="pf" value="0" checked>No</input><br> 
      <input type="text" class="form-control" name="pfn" value="Personal Folder Name"></input><br><br> 
      Please tag your file:<br> 
      <input type="radio" name="tag" value="other" checked>Other</input> 
      <input type="radio" name="tag" value="funny">Funny</input><br> 
      <input type="radio" name="tag" value="theoretic">Theoretic</input> 
      <input type="radio" name="tag" value="sad">Sad</input><br> 
      <input type="radio" name="tag" value="important">Important</input> 
      <input type="radio" name="tag" value="informative">Informative</input><br> 
      <input type="radio" name="tag" value="family">Family</input> 
      <input type="radio" name="tag" value="friendly">Friendly</input><br> 
      <input type="radio" name="tag" value="dangerous">Dangerous</input> 
      <input type="radio" name="tag" value="horrible">Horrible</input><br> 
      <input type="radio" name="tag" value="scary">Scary</input> 
      <input type="radio" name="tag" value="musical">Musical</input><br> 
      <input type="radio" name="tag" value="creative">Creative</input> 
      <input type="radio" name="tag" value="ugly">Ugly</input><br> 
     </div> 
     <div class="modal-footer"> 
     <b>Uploader breaks if ", ',/or \ is used anywhere.</b> 
     <button type="button" class="btn btn-default" data-dismiss="modal">Cancel request</button> 
     <input type="submit" id="uploadsubmit" class="btn btn-primary" value="Upload" name="submit"></input> 
     </form> 

을 그리고 다음 내 PHP 처리기 (upload.php로)입니다 :

HTML 양식 (내 웹 사이트에서 잘라 내기, 난 그냥 경우에 몇 부트 스트랩 요소를 왼쪽)

<center> 
<?php 

if(isset($_POST["disclaimer"]) && isset($_POST["realname"])) { 

if($_POST["disclaimer"] != "1") { 
    die("You didn't accept the disclaimer. Go back a page and read the disclaimer."); 
} 

if($_POST["realname"] == "Full name") { 
    die("You didn't enter your real name. Go back and try again."); 
} 

if($_POST["realname"] == "") { 
    die("You didn't enter your real name. Go back and try again."); 
} 

} else { 

    echo "Uh Oh! Something is going wrong! Attempting to repair.<br>"; 
    $_POST["realname"] == "real-name-post-error"; 

} 


$personalfolder = $_POST["pf"]; 

//Base file names 
$base_file_name = basename($_FILES["fileToUpload"]["name"]); 
$base_file_name_path = $_FILES["fileToUpload"]["name"]; 

if (!empty($_SERVER['HTTP_CLIENT_IP'])) { 
    $ip = $_SERVER['HTTP_CLIENT_IP']; 
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { 
    $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; 
} else { 
    $ip = $_SERVER['REMOTE_ADDR']; 
} 

//Main script 
echo "File(s) uploaded. Reading file list...<br>"; 
if($personalfolder == "1") { 
$target_dir_ext = time()."_".basename($_FILES["fileToUpload"]["name"])."_".$ip.$_POST["realname"]."/".$_POST["pfn"]; // Prevent file already existing 
} else { 
$target_dir_ext = time()."_".basename($_FILES["fileToUpload"]["name"])."_".$ip.$_POST["realname"]; // Prevent file already existing 
} 
$structure = "uploads/".$_POST["tag"]."/".$target_dir_ext; 
mkdir($structure, 0777, true); 
$target_dir = "uploads/".$_POST["tag"]."/".$target_dir_ext."/"; 
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); 
echo "File(s) detected: <br>".$target_file."<br>"; 
echo "Checking file(s)...<br>"; 

$uploadOk = 1; 
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION); 
// Check if file already exists 
if (file_exists($target_file)) { 
    echo "Sorry, file already exists.<br>"; 
    $uploadOk = 0; 
} 
// Check file size 
if ($_FILES["fileToUpload"]["size"] > 99999999) { 
    echo "Sorry, your file is too large.<br>"; 
    $uploadOk = 0; 
} 
// Allow certain file formats 
if($imageFileType != "jpg" 
&& $imageFileType != "png" 
&& $imageFileType != "jpeg" 
&& $imageFileType != "GIF" 
&& $imageFileType != "JPG" 
&& $imageFileType != "JPEG" 
&& $imageFileType != "PNG" 
&& $imageFileType != "mp3" 
&& $imageFileType != "MP3" 
&& $imageFileType != "WAV" 
&& $imageFileType != "wav" 
&& $imageFileType != "mp4" 
&& $imageFileType != "MP4" 
&& $imageFileType != "swf" 
&& $imageFileType != "SWF" 
&& $imageFileType != "ogg" 
&& $imageFileType != "OGG" 
&& $imageFileType != "js" 
&& $imageFileType != "JS" 
&& $imageFileType != "txt" 
&& $imageFileType != "TXT" 
&& $imageFileType != "exe" 
&& $imageFileType != "EXE" 
&& $imageFileType != "zip" 
&& $imageFileType != "ZIP" 
&& $imageFileType != "rar" 
&& $imageFileType != "RAR" 
&& $imageFileType != "msi" 
&& $imageFileType != "MSI" 
&& $imageFileType != "ttf" 
&& $imageFileType != "TTF" 
&& $imageFileType != "svg" 
&& $imageFileType != "SVG" 
&& $imageFileType != "eot" 
&& $imageFileType != "EOT" 
&& $imageFileType != "woff" 
&& $imageFileType != "WOFF" 
&& $imageFileType != "woff2" 
&& $imageFileType != "WOFF2" 
&& $imageFileType != "gif") { 
    echo "Sorry, only JPG, JPEG, PNG, GIF, OGG, MP3, MP4, WAV and SWF files are allowed.<br>"; 
    $uploadOk = 0; 
} 
// Check if $uploadOk is set to 0 by an error 
if ($uploadOk == 0) { 
    echo "Sorry, your file was not uploaded due to the reasons above.<br>"; 
// if everything is ok, try to upload file 
} else { 
    echo "File(s) OK. Attempting to move uploaded file(s) to the uploads directory..."; 
    if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { 
     echo "The file ". basename($_FILES["fileToUpload"]["name"]). " has been uploaded.<br>"; 
     $ul = "http://marksrtz.site50.net/uploader/".$target_file; 
     echo "File URL: <a href='".$ul."'>".$ul."</a><br>"; 
     if($imageFileType == "jpg" 
     || $imageFileType == "png" 
     || $imageFileType == "PNG" 
     || $imageFileType == "gif" 
     || $imageFileType == "GIF" 
     || $imageFileType == "jpeg" 
     || $imageFileType == "JPEG" 
     || $imageFileType == "JPG") { 
      echo 'Preview:<br><iframe width="1440px" height="900px" src="'.$ul.'"></iframe> '; 
     } else { 
      echo 'Preview:<br><iframe width="600px" height="400px" src="'.$ul.'"></iframe> '; 
     } 
    } else { 
     echo "Sorry, there was an error uploading your file."; 
    } 
} 
echo "<br>PHP Script was executed and ended correctly."; 
?> 
</center> 

문제는 무엇이 될 수 있습니까? PHP 스크립트의 출력은 다음과 같습니다 :

파일 업로드. 파일 목록 읽기 중 ... 탐지 된 파일 : 업로드/재미 있음/1422113393__188.29.64.63 마크 존스/파일 검사 중 ... 죄송합니다. 파일이 이미 존재합니다. 죄송합니다. JPG, JPEG, PNG, GIF, OGG, MP3, MP4, WAV 및 SWF 파일 만 허용됩니다. 죄송합니다. 위의 이유로 인해 파일이 업로드되지 않았습니다.

PHP 스크립트가 올바르게 실행되고 종료되었습니다.

는 무엇 이전에 감지되지 않은 것은 지금은 내가 전혀 업로드 할 파일을 전송하지 나중에

을 조금 일하기 시작했다 그 다음 $_POST["disclaimer"]$_POST["realname"]했지만.

그러나 enctype을 사용하면 파일을 보내지 만 POST 변수는 보내지 않습니다. 다른 양식을 만들지 않고 POST 변수와 파일을 동시에 보낼 수있는 방법이 있습니까?

+1

양식 업로드 유효한에 enctype을 필요로; 당신은 하나도 가지고 있지 않습니다. –

+0

그렇지 않으면 파일을 보내지 않고 일반 우편 변수 만 보냅니다. –

+0

@Fred -ii- 예. enctype을 사용할 때 면책 조항과 실명이 전송되는 것을 막습니다. enctype을 사용하지 않으면 면책 조항과 실제 이름을 전송하지만 파일을 업로드하지 않습니다 :/ – unknownA

답변

0

나는 이것을 풀어서 대답 할 것입니다.

000webhost의 기본 최대 업로드 크기는 2M입니다.

당신은 .htaccess를 사용하여 그 값을 변경하는 예를 들어

php_value memory_limit 30M 
php_value post_max_size 100M 
php_value upload_max_filesize 30M 

하고 서버의 루트에 배치 있음을 재정의 할 수 있습니다. php.ini 파일을 수정할 수 없으므로

Google에서 몇 가지 조사 결과가 나와 있습니다.

http://www.000webhost.com/forum/customer-assistance/202-file-upload-limit-2mb-set-php-ini.html

그것이 우리 내 구성 요소의 백엔드에서 서버 에 (파일 크기가 5 개 이상의 메가 바이트) 큰 파일을 업로드하는 것을 허용하지 않습니다 언급 한 것 같이 (사진 갤러리) 성명이이 업로드 파일 제한은 2Mb입니다 - php.ini에 의해 설정 나는 Joomla를 사용합니다. 5Mb까지 늘리는 방법을 아는 사람이 있습니까? 서버에 있거나 파일 시스템의 어딘가에 있습니까?

업로드 파일이 호스팅 한도는 2Mb의, 당신은 phpinfo에서 확인할 수있다().

플러스, 단지 인수의 이익을 위해 :

양식 업로드 유효한에 enctype을 필요로; 당신은 하나도 가지고 있지 않습니다.

변경이에 양식 :

<form action="upload.php" method="post" enctype="multipart/form-data"> 
0

우선 무엇이든지 POST Vars를 사용하지 마십시오! ALWAYS 그들을

대신

을 확인

$ personalfolder = $ _POST [ "PF"];

예컨대

$ personalfolder = trim (strip_tags (stripslashes ($ _ POST [ "pf"])))));

관련 문제