【问题标题】:How to upload image in Laravel using XAMPP如何使用 XAMPP 在 Laravel 中上传图片
【发布时间】:2014-05-04 15:18:45
【问题描述】:

这是代码:

<div class="fileupload fileupload-new" data-provides="fileupload">
<div class="fileupload-new thumbnail" style="width: 270px; height: 270px;">
<img src="http://localhost/storage/images/moimage.gif" />
</div>
<div class="fileupload-preview fileupload-exists thumbnail" style="max-width: 270px; max-height: 270px; line-height: 20px;"></div>
<div>
<span class="btn btn-file"; style="width:100%">
<span class="fileupload-new"><?php echo __('site.select_image'); ?></span>
<span class="fileupload-exists"><?php echo __('site.change'); ?></span>
<input type="file" name="image" />
</span>
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Delete</a>
</div>
</div>

这是行动:

if(Auth::can('upload_item_images'))
{
if(is_numeric($id) && Input::file('image.name') !== '')
{
$path = Config::get('application.upload_path') . DS . 'users' . DS . 'images' . DS .
$id . '.' . File::extension(Input::file('image.name'));
Bundle::start('resizer');
$success = Resizer::open(Input::file('image'))
->resize( 500 , 500 , 'crop' )
->save( $path , 90 );
}
}

这是应用程序上传路径:'upload_path' =&gt; path('public') . 'images'

我想将图像保存在图像/用户/图像中,但是当我上传图像时,它会发出一条成功完成但实际上图像没有添加到服务器的消息。

【问题讨论】:

    标签: php forms laravel laravel-3


    【解决方案1】:

    您必须在处理之前将图像保存到服务器。

    if(Auth::can('upload_item_images'))
    {
    if(is_numeric($id) && Input::file('image.name') !== '')
    {
    $path = Config::get('application.upload_path') . DS . 'users' . DS . 'images' . DS .
    $id . '.' . File::extension(Input::file('image.name'));
    Bundle::start('resizer');
    $name = Input::file('image')->getClientOriginalName();
    Input::file('image')->move($name);
    $success = Resizer::open($name)
    ->resize( 500 , 500 , 'crop' )
    ->save( $path , 90 );
    }
    }
    

    【讨论】:

    • 我试了还是一样,服务器上没有文件。
    猜你喜欢
    • 2019-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-29
    • 2018-08-11
    • 1970-01-01
    • 2020-01-11
    相关资源
    最近更新 更多