Skip to content
This repository was archived by the owner on Jul 12, 2019. It is now read-only.

added remote image catch support #56

Merged
merged 3 commits into from
Jul 20, 2018
Merged

Conversation

yueziii
Copy link
Contributor

@yueziii yueziii commented Jul 19, 2018

No description provided.

*/
public function __construct(array $result)
{
// $this->file = $file;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不需要的代码就删除,不需要保留

@@ -85,6 +86,90 @@ public function upload(Request $request)

return response()->json($response);
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

前面少了空行

$imgUrl = str_replace('&', '&', $imgUrl);
$pathRes = parse_url($imgUrl);
$queryString = isset($pathRes['query']) ? $pathRes['query'] : '';
$imgUrl = str_replace('?' . $queryString, '', $imgUrl);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不应该去掉图片 URL 的 query,很多图片带不带 query 是不同的

*/
private function download($url, $config)
{
$imgUrl = htmlspecialchars($url);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不建议对 URL 进行处理

fclose($file);
preg_match('/[\/]([^\/]*)[\.]?[^\.\/]*$/', $imgUrl, $m);
$original = $m ? $m[1] : '';
$ext = strtolower(strrchr($original, '.'));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

文件名与文件拓展,请使用 SplFile:

$img = new SplFileInfo('/path/to/file.jpg');
var_dump($img-> getExtension());  // "jpg"

http://php.net/manual/en/splfileinfo.getextension.php

@overtrue overtrue merged commit 7f61327 into overtrue:master Jul 20, 2018
yueziii added a commit to yueziii/laravel-ueditor that referenced this pull request Jul 20, 2018
Merge pull request overtrue#56 from yueziii/master
yueziii added a commit to yueziii/laravel-ueditor that referenced this pull request Jul 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants