php - 如何移动缩略图以在codeigniter中指定文件夹

标签 php ffmpeg codeigniter-3

我使用 ffmpeg 从视频中获得了缩略图。现在该缩略图存储在根文件夹项目目录中,但我想将其移动到特定文件夹。怎么做?我使用以下方法获得了缩略图...

<!DOCTYPE html>
<html>
  <body>
     <form action="upld.php" method="post" enctype="multipart/form-data">
        Select image to upload:
        <input type="file" name="fileToUpload" id="fileToUpload">
        <input type="submit" value="Upload" name="submit">
    </form>

    <?php
       if(isset($_POST['submit'])){
         $ffmpeg = "C:\\ffmpeg\\bin\\ffmpeg";
         $videoFile = $_FILES["fileToUpload"]["tmp_name"];
         $imageFile = "4.jpg";
         $size = "120*90";
         $getFromSecond = 5;
         $cmd = "$ffmpeg -i $videoFile -an -ss $getFromSecond -s $size $imageFile";
         if(!shell_exec($cmd)){
           echo "Thumbnail created";
         } else {
           echo "error while Thumbnail creating";
         }
      }
    ?>
</body>
</html>

最佳答案

用户 Codeigniter 的 图像处理类 .您可以在此处找到文档。 https://www.codeigniter.com/userguide3/libraries/image_lib.html

$filename = $this->input->post('fileToUpload');
$source_path = FCPATH . '/uploads/source/tmp/' . $filename;
$target_path = FCPATH. '/uploads/thumb/';
$config_manip = array(
    'image_library' => 'gd2',
    'source_image' => $source_path,
    'new_image' => $target_path,
    'maintain_ratio' => TRUE,
    'create_thumb' => TRUE,
    'thumb_marker' => '_thumb',
    'width' => 150,
    'height' => 150
);
$this->load->library('image_lib', $config_manip);
if (!$this->image_lib->resize()) {
    echo $this->image_lib->display_errors();
}
// clear //
$this->image_lib->clear();

这将对您有所帮助。

关于php - 如何移动缩略图以在codeigniter中指定文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45057762/

相关文章:

javascript - 有没有办法将菜单链接放到该菜单链接的子菜单中,并在您按下另一个选项之前保持选定的颜色?

php - 当php mysql中删除类别及其子类别时,如何更新帖子类别关系?

audio - FFMPEG - 如何在不转码的情况下将与视频分离的音频流保存到文件中

ffmpeg 不能同时运行 scale 和 hardsub

php - 原则 2 - 如何在多个 addSelect 中添加限制

php - 如何从多个嵌套if条件调用json

php - 修复 file_get_contents 权限被拒绝的错误

javascript - 使用函数调用调用 jquery 弹出窗口

linux - 在 FFMPEG 中选择出站 IP(eth0 或 eth1)

php - session_start() : Failed to decode session object