我正在使用laravel框架5.2。我正在使用dropzone用于多个图像。所有图像都成功存储在会话中。现在的问题是,当我在另一个函数中访问该特定会话时,它给我空白结果这里是我的balde文件和函数
enter code here
<---Dropzone-->
<div class="modal-body">
<div class="dropzone-img">
<form id="my-awesome-dropzone" action="{{ url('/add-images')}}" class="fallback dropzone">
{{ csrf_field() }}
</div>
</div>
现在我的控制器有两个功能
enter code here
public function add_images(Request $request){
if($request->ajax()){
$image=$_FILES['file'];
if(!empty($image)){
if($image['error']==0){
$imgName = pathinfo($_FILES['file']['name']);
$ext = $imgName['extension'];
$rand=mt_rand(5,1000000000).'.'.$ext;
$destination=realpath('../public/images/ListingImages').'/';
if(move_uploaded_file($image['tmp_name'], $destination.$rand)){
$request->session()->put('businessimages.'.$imgName['filename'].'.image',$rand);
$images = $request->session()->get('businessimages');
echo "<pre>"; print_r($images); die;
}
}
}
}
}
Now when i accessed the businessimages session in another function it gives me empty result.
public function business_for_sale(Request $request){
$images = $request->session()->get('businessimages');
echo "<pre>"; print_r($images); die;
}
任何人都可以帮助我。在此先感谢:)
答案 0 :(得分:2)
我认为问题在于你在设置会话时调用die()函数
$request->session()->put('businessimages.'.$imgName['filename'].'.image',$rand);
$images = $request->session()->get('businessimages');
echo "<pre>"; print_r($images); die;
你可以看到它 Does die() end your session in PHP?
所以你可以试着像
一样改变它$request->session()->put('businessimages',$rand);
$images = $request->session()->get('businessimages');
echo "<pre>"; print_r($images);
session_register_shutdown();
die;