我有问题,让用户通过ajax请求>路由>控制器@方法在laravel 4中创建文件夹。
我没有测试ajax成功请求的URL调用权的方法。
当我使用mkdir
或File::mkdir($path);
(这种方法是否存在?)时,我将得到响应Failed to load resource: the server responded with a status of 500 (Internal Server Error)
并且无法创建新文件夹..如何解决它?在laravel中创建文件夹
route.php
Route::post('admin/article/addimagegallery', '[email protected]');
AdminDashboardController
public function addImagegallery()
{
if (Request::ajax())
{
…
$galleryId = 1; // for test
$path = public_path().'/images/article/imagegallery/'.$galleryId;
File::mkdir($path);
}
}
JS
$.ajax({
url: 'addimagegallery',
type: 'POST',
data: {addimagegallery: 'addimagegallery'},
})
.done(function(response) {
console.log(response);
});
你可能会在这有趣也http://stackoverflow.com/questions/30682421/how-to-protect-image-from-public-view-in-laravel-5/30682456#30682456你在哪里创建你的已写入文件夹中的图像。 –