【问题标题】:Can you give a help understanding how to properly solve "Image not found or type unkown."?您能否帮助了解如何正确解决“找不到图像或键入未知。”?
【发布时间】:2018-12-22 03:09:48
【问题描述】:

我正在使用 laravel-tinymce-simple-imageupload,因此可以使用 tinymce 插件进行图片上传,但我收到错误“Image not found or type unkown.

要解决这个问题,似乎有必要更改上传图像的 url 路径,以便使用绝对 url 部分。但是,作为初学者,我不了解如何进行此配置。

貌似TinymceController里面默认有个函数uploadImage()实现了图片上传的方法。 (https://github.com/petehouston/laravel-tinymce-simple-imageupload#some-notes)

在那个页面里还说我们可以自定义上传的url,这样当上传表单包含在“@include('mceImageUpload::upload_form);”中时,我们可以传入处理post图片上传的url,比如"@include('mceImageUpload::upload_form', ['upload_url' => 'YOUR_URL_FOR_HANDLING_IMAGE_UPLOAD'])” .

但我不明白在控制器中创建什么是必要的,以及在“YOUR_URL_FOR_HANDLING_IMAGE_UPLOAD”中需要什么。 您能否帮助了解如何正确实现这一目标?


解释我拥有的代码。在视图中有一个文本区域供用户介绍一些内容:

<textarea rows="3" name="content"></textarea>

包含upload_form:

@include('mceImageUpload::upload_form')

还有用于 Tinymce 的 jQuery:

tinymce.init({
          selector:'textarea',
           plugins: 'image code link',
           relative_urls: false,
           file_browser_callback: function(field_name, url, type, win) {
          // trigger file upload form
              if (type == 'image') $('#formUpload input').click();
                    }
   });

在控制器中我有下面的代码来获取文本区域的内容

    // store in the column content the content introduced in the textarea
    $post->content = $request->content;
    $post->save();

    // then i want to download a pdf with the post content

    $pdf = app()->make('dompdf.wrapper');
    $pdf->loadHTML($request->content);
    return $pdf->download('test.pdf');

图片存储在数据库中的内容格式如下:

<p>test content<img src="/img/image_100.jpeg" width="1200" height="900" /></p>

但在 pdf 中,图像不会出现,而是出现“找不到图像或键入未知”。

【问题讨论】:

标签: php jquery laravel dompdf


【解决方案1】:

如果&lt;p&gt;test content&lt;img src="/img/image_100.jpeg" width="1200" height="900" /&gt;&lt;/p&gt;

就是这样,您实际上应该手动查看您的主机文件路径以了解发生了什么,除此之外,您的表单已经建立了一个执行操作的路径,所以再次,您应该检查您的 Controller 并查看发生了什么对了,您是确定图像保存路径的人,只需手动查看图像的存储位置,它就会为您提供所有答案。

【讨论】:

  • 您实际上是在代码的哪一部分上传图片?
  • 我正在使用这个包,它似乎是包含那部分代码的包。这似乎是允许上传图像的“@include('mceImageUpload::upload_form')”。在 jQuery 中有这部分“if (type == 'image') $('#formUpload input').click();”。
猜你喜欢
  • 2021-11-23
  • 2017-03-23
  • 1970-01-01
  • 2021-12-25
  • 1970-01-01
  • 2012-09-15
  • 1970-01-01
  • 2021-01-04
  • 1970-01-01
相关资源
最近更新 更多