如何在PHP中上传和移动最多15MB的视频

时间:2016-12-29 11:13:04

标签: php

$mimg=strtolower(substr($_FILES['video1']['name'], strrpos($_FILES['video1']['name'], '.') + 1));
$ext =  $lastid.".".$mimg;

$target_dir = "wp-content/plugins/videos/includes/uploads/".$ext;

$ss=move_uploaded_file($_FILES["video1"]["tmp_name"], $target_dir);

$imageFileType = pathinfo($target_dir,PATHINFO_EXTENSION);
//$ex = $lastid.".".$imageFileType;

if($imageFileType != "mp4" && $imageFileType != "avi" && $imageFileType != "mov" && $imageFileType != "3gp" && $imageFileType != "mkv")
{
    echo "File Format Not Suppoted";
} 
else
{
    if($ss){
    $update2=$wpdb->query("update wp_videos set video1='".$ext."' where id='".$lastid."'");
        if($update2)
        echo "uploaded ";
    }
}

4 个答案:

答案 0 :(得分:0)

您可以执行以下操作:

ini_set('upload_max_filesize', '15M');
ini_set('post_max_size', '15M');

答案 1 :(得分:0)

您需要在upload_max_filesize

中设置post_max_sizephp.ini的值
upload_max_filesize = 15M

post_max_size = 15M

您需要重新启动服务器才能使用新配置。

如果你不能改变你的php.ini,那你就不走运了。您无法在运行时更改这些值;上传文件大于php.ini中指定的值将在执行到达ini_set()的调用时失败

答案 2 :(得分:0)

您需要在php.ini或.htaccess中设置upload_max_filesize和post_max_size的值:

; Maximum allowed size for uploaded files.
upload_max_filesize = 40M

; Must be greater than or equal to upload_max_filesize
post_max_size = 40M

答案 3 :(得分:0)

const helpsPosted = {
  chartData: {
    labels: [
      "January", 
      "February", 
      "March", 
      "April", 
      "May", 
      "June", 
      "July", 
      "August", 
      "September", 
      "October",
      "November",
      "December",
    ],
    datasets: [
      {
        label: "Helps posted",
        fill: false,
        lineTension: 0.1,
        backgroundColor: "rgba(75,192,192,0.4)",
        borderColor: "rgba(75,192,192,1)",
        borderCapStyle: 'butt',
        borderDash: [],
        borderDashOffset: 0.0,
        borderJoinStyle: 'miter',
        pointBorderColor: "rgba(75,192,192,1)",
        pointBackgroundColor: "#fff",
        pointBorderWidth: 1,
        pointHoverRadius: 5,
        pointHoverBackgroundColor: "rgba(75,192,192,1)",
        pointHoverBorderColor: "rgba(220,220,220,1)",
        pointHoverBorderWidth: 2,
        pointRadius: 1,
        pointHitRadius: 10,
        data: [65, 59, 80, 81, 56, 55, 40, 40, 0, 21, 10, 0],
        spanGaps: false,
      },
    ],
  },
};