我有一個PHP文件上傳到位,其中表單目標是一個iframe。照片上傳不上傳大於2MB的文件
它上傳的文件小於2mb罰款。但更大的東西不會上傳。我在代碼中看不到任何理由。
<div id="upload_wrapper">
<img src="../images/logo.png" alt="logo5" width="" height="" style="padding:0px;" />
<h3>Profile picture upload</h3>
<form id="upload" name="upload" enctype="multipart/form-data" method="post" action="index.php" target="upload_target">
<input name="folder" type="hidden" value="<?php echo $folder ?>" />
<input name="filename" type="hidden" value="<?php echo $filename ?>" />
<input name="uploaded_file" type="file" size="5120" id="uploaded_file" />
<input id="sent" name="sent" type="submit" value="Upload" />
</form>
</div>
<div id="loading" style="background:url(ajax-loader.gif) no-repeat left; height:50px; width:370px; display:none;">
<p style="margin-left:40px; padding-top:15px;">Uploading File... Please wait</p>
</div>
<div id="image_wrapper" style="display:none;"><p id="preview"></p></div>
<iframe id="upload_target" name="upload_target" style="width:10px; height:10px; display:none"></iframe>
</div>
而且繼承人的PHP上傳代碼
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$targetFolder = $_POST['folder'] . "/";
$filename2 = $_POST['filename'];
if (!is_dir($targetFolder))
{
mkdir($targetFolder, 0777);
}
$tempFile = $_FILES['uploaded_file']['tmp_name'];
$targetPath = dirname(__FILE__) . '/' . $targetFolder;
$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['uploaded_file']['name'];
// Validate the file type
$fileTypes = array('jpg'); // File extensions
$fileParts = pathinfo($_FILES['uploaded_file']['name']);
if (in_array($fileParts['extension'],$fileTypes))
{
$uploadfile = $targetFolder. basename($filename2 .".".$fileParts['extension']);
move_uploaded_file($tempFile,$uploadfile);
$fileName = $uploadfile;
}
echo "<div id='filename'>$fileName</div>";
}
可能是因爲將POST數據限制爲2MB的服務器/ php配置。 –
http://stackoverflow.com/questions/2184513/php-change-the-maximum-upload-file-size只是編輯你的php.ini文件 –