dongyilu3143 2018-07-21 07:09
浏览 134
已采纳

Laravel 5.6 Ajax Post 500内部服务器错误

Hello i am sending large string data via Ajax Post Request and its working fine on localhost but not working on live server i am sending some image data then this image data is converted to images on server..also its taking so much time to send this data average data size is between 4 to 7 MB..also can you suggest a better way so it can be done quickly..also things are setup properly i am including CSRF token and URL is also good but don't know why this error is occurring

Error => Status Code: 500 Internal Server Error

My controller code where i am sending request

$pid    =  $request->input('id');
        $pt_id  =  $request->input('pt_id');
        $pname  =  $request->input('name');
        $isBack =  $request->input('isBack');
        $qty    =  $request->input('qty');
        $paper  =  $request->input('paper');
        $previewFront  =  $request->input('previewFront');
        $previewBack   =  $request->input('previewBack');
        $PrintDataFront  =  $request->input('PrintDataFront');
        $PrintDataBack   =  $request->input('PrintDataBack');
        $cart_item_id = uniqid();
        //Store Img Data
        $pf = str_replace('data:image/png;base64,', '', $previewFront);
        $pf = str_replace(' ', '+', $pf);
        $pf_n = $cart_item_id.'_f_.'.'png';
        \File::put(public_path(). '/cart_preview/' . $pf_n, base64_decode($pf));
        $pb = str_replace('data:image/png;base64,', '', $previewBack);
        $pb = str_replace(' ', '+', $pb);
        $pb_n = $cart_item_id.'_b_.'.'png';
        \File::put(public_path(). '/cart_preview/' . $pb_n, base64_decode($pb));
        $pdf = str_replace('data:image/png;base64,', '', $PrintDataFront);
        $pdf = str_replace(' ', '+', $pdf);
        $pdf_n = $cart_item_id.'_f_.'.'png';
        \File::put(public_path(). '/orders/' . $pdf_n, base64_decode($pdf));
        $pdb = str_replace('data:image/png;base64,', '', $PrintDataBack);
        $pdb = str_replace(' ', '+', $pdb);
        $pdb_n = $cart_item_id.'_b_.'.'png';
        \File::put(public_path(). '/orders/' . $pdb_n, base64_decode($pdb));
        //Get Prices and qty
        $opriceitem = PriceTableItem::find($qty);
        $itemQty = $opriceitem->qty;
        $basePrice = $opriceitem->total;
        if($isBack == 'true') {
            $backPrice =  $opriceitem->total_back;
            $itemPrice = $opriceitem->total + $opriceitem->total_back;
            $pricePerPiece = $opriceitem->item_price + $opriceitem->item_price_back;            
        }else {
            $backPrice =  'INCLUDED';
            $itemPrice = $opriceitem->total; 
            $pricePerPiece = $opriceitem->item_price; 
        }
        if($paper == 'Premium White') {
            $paperPrice = ($itemPrice/100) *60;
            $itemPrice = $itemPrice + ($itemPrice/100) *60;
        } else {
            $paperPrice = 'INCLUDED';
        }
        //Get all Available Qty
        $allQty = PriceTableItem::where('tid', $pt_id)->get();
        $allAvailableQty = array();
        foreach($allQty as $allqtyarry) {array_push($allAvailableQty, $allqtyarry->qty);}       
        //Create Cart Object
        $item = [
            "id"      => $cart_item_id,
            "pid"      => $pid,
            "name"    => $pname,
            "qty"     => $itemQty,
            "price_table_id"    => $pt_id,
            "paperType"  => $paper,
            "backCharges"  => $backPrice,
            "paperCharges"  => $paperPrice,
            "isBack" => $isBack,
            "pricePerPiece"    => $pricePerPiece,
            "basePrice"    => $basePrice,
            "totalPrice"    => $itemPrice,
            "allQty"    => $allAvailableQty,
        ];
        $request->session()->put('cart.items.' . $cart_item_id, $item);
        return 'Success';
  • 写回答

1条回答 默认 最新

  • drsxzut183207938 2018-07-21 11:50
    关注

    Blockquote Are you getting only error 500 and nothing else? If so, enable debug so you can get better description of the error. Make sure your php.ini file is set up properly and also permissions are fine for your server folders (I always get problems with the storage folder).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 cv::resize不同线程时间不同
  • ¥15 web课程,怎么做啊😭没好好听课 根本不知道怎么下手
  • ¥15 做一个关于单片机的比较难的代码,然后搞一个PPT进行解释
  • ¥15 python提取.csv文件中的链接会经常出现爬取失败
  • ¥15 数据结构中的数组地址问题
  • ¥15 maya的mel里,怎样先选择模型A,然后利用mel脚本自动选择有相同名字的模型B呢。
  • ¥15 Python题,根本不会啊
  • ¥15 会会信号与系统和python的来
  • ¥15 关于#python#的问题
  • ¥20 oracle RAC 怎么配置啊,配置