尊龙凯时人生就是博

laravel5.6 Îļþɾ³ý

×÷ΪһÃû¿ª·¢Õߣ¬ÎÒÃǾ­³£ÐèÒª¶ÔÎÒÃǵijÌÐò¾ÙÐÐά»¤ºÍ¸üУ¬ÕâÒ²°üÀ¨¶ÔÎļþ¾ÙÐÐɾ³ý¡£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚ laravel 5.6 ÖÐɾ³ýÎļþ¡£

ÔÚ Laravel ÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃÎļþϵͳÀ´ÖÎÀíÎÒÃǵÄÎļþ¡£Laravel 5.6 ÖÐÌṩÁ˼¸ÖÖÎļþϵͳ£¬ÀýÈçÍâµØÎļþϵͳ¡¢ÔÆ´æ´¢ÎļþϵͳµÈ¡£

Õë¶Ô²î±ðµÄÎļþϵͳ£¬É¾³ýÎļþµÄÒªÁìÒ²²î±ð¡£ÒÔÏÂÊÇÕë¶ÔÍâµØÎļþϵͳµÄÎļþɾ³ýÒªÁì¡£

Ê×ÏÈ£¬ÎÒÃÇÐèҪȷ¶¨ÒªÉ¾³ýµÄÎļþµÄ·¾¶¡£ÔÚ Laravel ÖУ¬ÎÒÃÇ¿ÉÒÔʹÓà public_path() º¯ÊýÀ´»ñÈ¡¹«¹²Ä¿Â¼µÄÍêÕû·¾¶¡£ÀýÈ磬ÈôÊÇÎÒÃÇҪɾ³ý public/uploads/example.txt Îļþ£¬ÎÒÃÇ¿ÉÒÔÕâÑùд£º

$file_path = public_path('uploads/example.txt');

µÇ¼ºó¸´ÖÆ

È»ºó£¬ÎÒÃÇ¿ÉÒÔʹÓà PHP ×Ô´øµÄ unlink() º¯ÊýÀ´É¾³ýÎļþ¡£ÀýÈ磬ÎÒÃÇ¿ÉÒÔÕâÑùд£º

if (file_exists($file_path)) {
    unlink($file_path);
}

µÇ¼ºó¸´ÖÆ

ÉÏÃæµÄ´úÂë»á¼ì²éÎļþÊÇ·ñ±£´æ£¬ÈôÊDZ£´æÔòɾ³ý¸ÃÎļþ¡£

ÈôÊÇÄãÏëÔÚɾ³ýÎļþ֮ǰ¾ÙÐÐһЩ²Ù×÷£¬ÀýÈ籸·ÝÎļþ»ò¼Í¼ɾ³ýÈÕÖ¾£¬Äã¿ÉÒÔÌí¼Ó×Ô¼ºµÄ´úÂë¡£ÀýÈ磬Äã¿ÉÒÔÔÚɾ³ýÎļþ֮ǰ½«Îļþ¸´ÖƵ½ÐµÄĿ¼£º

$new_path = public_path('backups/example.txt');
if (file_exists($file_path)) {
    copy($file_path, $new_path);
    unlink($file_path);
    // ¼Í¼ÈÕÖ¾
}

µÇ¼ºó¸´ÖÆ

ÉÏÃæµÄ´úÂë»áÔÚɾ³ýÎļþ֮ǰ£¬½«Îļþ¸´ÖƵ½ backups Ŀ¼Ï£¬²¢¼Í¼ÈÕÖ¾¡£

×¢ÖØ£¬ÈôÊÇҪɾ³ýµÄÎļþÔÚ¹«¹²Ä¿Â¼ÒÔÍ⣬ÄãÐèҪʹÓà storage_path() º¯ÊýÀ´»ñÈ¡ÎļþµÄÍêÕû·¾¶¡£ÀýÈ磬ÈôÊÇҪɾ³ý storage/app/example.txt Îļþ£¬Äã¿ÉÒÔÕâÑùд£º

$file_path = storage_path('app/example.txt');

µÇ¼ºó¸´ÖÆ

×ܽáÀ´Ëµ£¬É¾³ýÎļþµÄ°ì·¨ÈçÏ£º

È·¶¨ÒªÉ¾³ýµÄÎļþµÄ·¾¶¡£

ͨ¹ýÎļþϵͳ»ò PHP ×Ô´øº¯ÊýÀ´É¾³ýÎļþ¡£

3.£¨¿ÉÑ¡£©ÔÚɾ³ýÎļþ֮ǰ¾ÙÐÐÐèÒªµÄ²Ù×÷¡£

ÔÚ¿ª·¢Àú³ÌÖУ¬ÊµÊ±É¾³ý²»ÔÙʹÓõÄÎļþ¿ÉÒÔ½ÚÔ¼´æ´¢¿Õ¼äºÍÌá¸ßÐÔÄÜ¡£Laravel 5.6 ÌṩÁ˼òÆÓµÄÒªÁìÀ´É¾³ýÎļþ£¬½¨Ò鿪·¢ÕßÔÚÊʵ±µÄʱ¼äʹÓá£

ÒÔÉϾÍÊÇlaravel5.6 Îļþɾ³ýµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

13452372176

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

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

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