slove
V2EX  ›  问与答

下面是一段上传图片,然后使用标题生成链接,只支持英文和数字,望懂的人帮忙处理下,让他支持中文标题

  •  
  •   slove · Jun 9, 2014 · 3347 views
    This topic created in 4380 days ago, the information mentioned may be changed or developed.
    $photo = new photo();
    $photo->title = $input['upload_title'];
    $photo->slug = Str::slug($input['upload_title']);
    $photo->belongs_to = $input['belongs_to'];
    $photo->credits = strlen($input['credits']) > 0 ? $input['credits'] : '';
    $photo->photo_url = $randomName;
    $photo->type = 'image';
    $photo->user_id = Auth::user()->id;
    $photo->read_count = 0;
    $photo->is_approved = ((int) Settings::first()->autoapprove_photos === 0) ? 0 : 1;
    $photo->is_featured = 0;
    $photo->save();

    return Response::json(array(
    'status' => 'success',
    'message' => trans('app.upload_success'),
    'redirect_to' => \URL::to('photo/' . Str::slug($input['upload_title']))
    ));
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2942 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 00:18 · PVG 08:18 · LAX 17:18 · JFK 20:18
    ♥ Do have faith in what you're doing.