[英]MediawikiPlayer extension not working for 3gp,mp4,mp3 extension
[英]Uploading file is not working with mp3 and mp4
<form action="test.php" method="POST" enctype="multipart/form-data">
Select image to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload Image" name="submit">
</form>
在這里,這是處理圖像,但不適用於 mp3、mp4,我也更改了 .ini 文件中的 upload_max_size 但這不起作用
$target_dir = "videos/";
echo '<br>';
echo $target_file = $target_dir . $_FILES['fileToUpload']['name'];
$uploadOk = 1;
echo '<br>';
//$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
echo 'started';
echo '<br>';
echo $check = $_FILES['fileToUpload']['tmp_name'];
if($check !== false) {
move_uploaded_file($check,$target_file);
echo 'Uploaded';
} else {
echo "File is not an image.";
$uploadOk = 0;
}
}
?>
看起來您還應該設置其他 php.ini 變量,例如:
但是你總是可以發送大於這個限制的文件(然后超全局 _POST 和 _FILES 是空的)所以我認為最好的做法是像這樣使用 sth
if ( $_SERVER['REQUEST_METHOD'] == 'POST' && empty($_POST) &&
empty($_FILES) && $_SERVER['CONTENT_LENGTH'] > 0 )
{
$displayMaxSize = ini_get('post_max_size');
switch ( substr($displayMaxSize,-1) )
{
case 'G':
$displayMaxSize = $displayMaxSize * 1024;
case 'M':
$displayMaxSize = $displayMaxSize * 1024;
case 'K':
$displayMaxSize = $displayMaxSize * 1024;
}
$error = 'Posted data is too large. '.
$_SERVER[CONTENT_LENGTH].
' bytes exceeds the maximum size of '.
$displayMaxSize.' bytes.";
}
代碼螞蟻解釋可以在這里找到: http : //andrewcurioso.com/blog/archive/2010/detecting-file-size-overflow-in-php.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.