Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image (Symfony 4)Liip/Imagine can';找不到我上传的图像_Image_File_Path_Upload - Fatal编程技术网

Image (Symfony 4)Liip/Imagine can';找不到我上传的图像

Image (Symfony 4)Liip/Imagine can';找不到我上传的图像,image,file,path,upload,Image,File,Path,Upload,我将图像上传到S3服务器没有问题(因此我知道我的图像路径是合法的),但是当我尝试使用Liip/Imagine服务创建一些重新调整大小的图像时,Liip/Imagine找不到我上传的图像 我按如下方式转储图像路径: $idFile = $form['idFile']->getData(); dump($idFile); die(); 以下是转储的外观: ProfileController.php on line 340: UploadedFile {#64 ▼ -test: false

我将图像上传到S3服务器没有问题(因此我知道我的图像路径是合法的),但是当我尝试使用Liip/Imagine服务创建一些重新调整大小的图像时,Liip/Imagine找不到我上传的图像

我按如下方式转储图像路径:

$idFile = $form['idFile']->getData();
dump($idFile);
die();
以下是转储的外观:

ProfileController.php on line 340:
UploadedFile {#64 ▼
  -test: false
  -originalName: "file-name.png"
  -mimeType: "image/png"
  -error: 0
  path: "/tmp"
  filename: "php09sJr3"
  basename: "php09sJr3"
  pathname: "/tmp/php09sJr3"
  extension: ""
  realPath: "/tmp/php09sJr3"
  aTime: 2019-02-24 22:54:00
  mTime: 2019-02-24 22:54:00
  cTime: 2019-02-24 22:54:00
  inode: 12586620
  size: 97901
  perms: 0100600
  owner: 997
  group: 995
  type: "file"
  writable: true
  readable: true
  executable: false
  file: true
  dir: false
  link: false
}
我知道这个路径(/tmp/php09sJr3)是合法的,因为我的文件都可以完美地上传到我的S3存储桶中,但是当我尝试在我的控制器中创建缩略图时:

public function saveProfileEditAction(Request $request, FilterService $imagine)
{
    $form = $this->createForm(UserProfileType::class, $user);
    $form->handleRequest($request);

    if($form->isSubmitted() && $form->isValid())        {
        $idFile = $form['idFile']->getData();

        if ($idFile != null){
            // this command right here 
            $resourcePath = $imagine->getUrlOfFilteredImage($idFile->getPathName(), 'my_thumb');
我得到以下错误:

Source image not resolvable "/tmp/php09sJr3" in root path(s) "/var/www/vhosts/mywebsite.com/public"
更令人困惑的是,当我检查时,
/tmp
/var/www/vhosts/mywebsite.com/public/tmp
中没有任何内容,但是我的文件仍然完美地上传到S3

这是我的配置liip_imagine.yaml文件:

liip_imagine :
    # configure resolvers
    resolvers :
        # setup the default resolver
        default :
            # use the default web path
            web_path : ~
    # your filter sets are defined here
    filter_sets :
        # use the default cache configuration
        cache : ~
        # the name of the "filter set"
        my_thumb :
            # adjust the image quality to 75%
            quality : 75
            # list of transformations to apply (the "filters")
            filters :
                # create a thumbnail: set size to 120x90 and use the "outbound" mode
                # to crop the image when the size ratio of the input differs
                thumbnail  : { size : [120, 90], mode : outbound }
                thumb_square :  { size : [300, 300], mode : outbound }
                thumb_rectangle_md : { size : [670, 400], mode : outbound }
                thumb_hd : { size : [1920, 1080], mode : outbound }
                # create a 2px black border: center the thumbnail on a black background
                # 4px larger to create a 2px border around the final image
                background : { size : [124, 94], position : center, color : '#000000' }

我如何正确地告诉Liip/Imagine我上传文件的文件路径

您必须将其添加到yaml配置文件中(我的是liip_imagine.yaml):

因此,在文件的范围内,它将如下所示:

liip_imagine :
    # configure resolvers
    resolvers :
        # setup the default resolver
        default :
            # use the default web path
            web_path : ~
# !!!!!!!!!!!!!!!!!!!!!START!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    loaders:
        default:
            filesystem:
                data_root: "/"
# !!!!!!!!!!!!!!!!!!!!!END!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    # your filter sets are defined here
    filter_sets :
        # use the default cache configuration
        cache : ~
        # the name of the "filter set"
        my_thumb :
            # adjust the image quality to 75%
            quality : 75
            # list of transformations to apply (the "filters")
            filters :
                # create a thumbnail: set size to 120x90 and use the "outbound" mode
                # to crop the image when the size ratio of the input differs
                thumbnail  : { size : [120, 90], mode : outbound }
                resize : { size : [670, 400], mode : outbound }
                # create a 2px black border: center the thumbnail on a black background
                # 4px larger to create a 2px border around the final image
                background : { size : [124, 94], position : center, color : '#000000' }
然后,Liip将创建缩略图、调整大小等。。。并将文件移动到:

http://www.yourwebsite.com/media/cache/my_thumb/tmp/phpSQFUF1
从技术上讲,在您的服务器中,它将是根文件夹中的
/public/media/cache/my_thumb/tmp
文件夹

http://www.yourwebsite.com/media/cache/my_thumb/tmp/phpSQFUF1