【问题标题】:laravel path of files in (windows) localhost(Windows)localhost中文件的laravel路径
【发布时间】:2018-10-10 20:28:23
【问题描述】:

此测试在 localhost/windows/php/apache/mysql 上进行

例如:

在公共文件夹的根目录中:

$path = '/upload/images/accounts/12005/thumbnail_profile_eBCeBawXWP.jpg';

我想用它:

$img->save($path);

我收到此错误:

"无法将图像数据写入路径 (/upload/images/accounts/12005/thumbnail_profile_eBCeBawXWP.jpg)"

我尝试修复它:

$path = public_path($path);
$img->save($path);

所以我得到了这个错误:

"无法将图像数据写入路径 (D:\Server\data\htdocs\laravel\jordankala.com\public_html\ /upload/images/accounts/12005/thumbnail_profile_pH657T62fl.jpg)

大概,在真正的服务器(linux)中,我不会有这个问题和码字。

现在我该如何处理这个错误? (我希望它可以在 windows localhost 和真正的 linux 服务器上工作)

【问题讨论】:

标签: php laravel


【解决方案1】:

你可以用它来保存你的路径

$file = $request->file('image_field_name'); $destinationPath = 'upload/images/accounts/12005/'; $uploadedFile = $file->move($destinationPath,$file->getClientOriginalName()); //move the file to given destination path

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-04-07
    • 2016-03-19
    • 2018-07-25
    • 2021-10-20
    • 1970-01-01
    • 1970-01-01
    • 2020-10-03
    • 1970-01-01
    相关资源
    最近更新 更多