如何移动缩略图以在代码点火器中指定文件夹



我使用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();

这将对您有所帮助。

最新更新