weixin_33701564 2016-01-08 16:56 采纳率: 0%
浏览 139

Laravel字符集-UTF8

I'm using Laravel 5 and i'm making an AJAX request with which the user can create a directory. But if the user uses a Cyrillic alphabet the newly created dir appears to be strange: РЎРЅРёРјРєРё. This is the ajax:

$.ajax({
       async: true,                      
       method: 'POST',
       dataType: 'json',
       url: '../public/createfolder',
       data: {foldername: $('#folder-name').val(), "_token": csrf},
       complete: function(response) {
           console.log(response);                  
       }
});

And that's how I catch the request:

public function createFolder(){
        $foldername = $_POST['foldername'];
        $ds = DIRECTORY_SEPARATOR;
        $userid = Auth::id();
        Storage::disk('local')-> makeDirectory('uploads'.$ds.$userid.$ds.$foldername);
    }

How can this be avoided?

  • 写回答

1条回答 默认 最新

  • derek5. 2016-01-08 23:14
    关注

    I suppose your directory names are stored in the database. In this case, you can just create the actual directories with the name as their id in the database.

    Also you don't really have to create a directory, even if the user thinks he's creating it. Unless you allow the user to access it through FTP, there's no need to create it. You can have a single directory for each user and assign the files in the database to a virtual directory, that's only displayed to the user, even though the files are all in the same location.

    评论

报告相同问题?

悬赏问题

  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。
  • ¥20 CST怎么把天线放在座椅环境中并仿真