尊龙凯时人生就是搏

laravel ÏÂÔع¦Ð§²»¿ÉÓÃÖÐÎÄ

ÔÚʹÓà laravel ¿ª·¢Ê±£¬ÎÒÃÇ¿ÉÄÜ»áÓöµ½ÏÂÔع¦Ð§²»¿É¹»×¼È·´¦ÀíÖÐÎÄÎļþÃûµÄÎÊÌâ¡£Õâ¸öÎÊÌâÖ÷ÒªÊÇÓÉÓÚÔÚÎļþÃûÖаüÀ¨ÓÐÖÐÎÄ×Ö·ûËùµ¼ÖµÄ¡£Òª½â¾öÕâ¸öÎÊÌ⣬ÎÒÃÇÐèÒª¶ÔÎļþÃû¾ÙÐÐ url ±àÂë¡£

ÔÚ PHP ÖУ¬¿ÉÒÔʹÓà urlencode() º¯ÊýÀ´¶ÔÎļþÃû¾ÙÐбàÂë¡£¿ÉÊÇ£¬ÔÚ Laravel ÖÐÎÒÃÇ¿ÉÒÔʹÓÃÄÚÖÃµÄ Str::slug() ÒªÁìÀ´Íê³ÉÕâ¸öʹÃü¡£

Str::slug() ÒªÁì¿ÉÒÔ½«Ò»¸ö×Ö·û´®×ª»¯Îª URL ÓÑºÃµÄ “slug” ÃûÌ᣿ÉÊÇ£¬ÎÒÃÇ¿ÉÒÔÑ¡Ôñ²»´«ÈëµÚ¶þ¸ö²ÎÊý£¬ÒÔ±£´æÔ­ÓÐ×Ö·û£¬Ö»¾ÙÐÐ URL ±àÂë¡£

ÏÂÃæÊÇÒ»¸öʾÀý´úÂ룺

public function downloadFile($filename) {
    $fullPath = storage_path('app/download/' . $filename);
    $headers = [
        'Content-Type' => 'application/octet-stream',
    ];
    $escapedFilename = Str::slug($filename, '');
    return response()->download($fullPath, $escapedFilename, $headers);
}

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄ´úÂëÖУ¬ÎÒÃÇʹÓÃÁË Str::slug() ÒªÁ콫ÎļþÃû¾ÙÐÐÁ˱àÂ룬²¢½«±àÂëºóµÄ×Ö·û´®×÷ΪµÚ¶þ¸ö²ÎÊýת´ï¸ø download() ÒªÁì¡£

ͨ¹ýÕâÖÖ·½·¨£¬ÎÒÃÇ¿ÉÒÔÈ·±£ Laravel ÔÚ´¦ÀíÏÂÔØÎļþʱÄܹ»×¼È·´¦Àí°üÀ¨ÖÐÎÄ×Ö·ûµÄÎļþÃû¡£

ÒÔÉϾÍÊÇlaravel ÏÂÔع¦Ð§²»¿ÉÓÃÖÐÎĵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是搏ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是搏ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ