×ðÁú¿­Ê±¹ÙÍøµÇ¼

laravelÔõôɾ³ýĿ¼ÖеÄͼƬ

laravel ÊÇÒ»¿îÊ¢ÐÐµÄ php ¿ò¼Ü £¬ËüÌṩÁËÐí¶àÓÐÓõĹ¦Ð§ £¬ÉÁ¿ª·¢ÕßÔÚ¿ª·¢Àú³ÌÖÐÔ½·¢¸ßЧ¡¢±ã½Ý¡£ÔÚÐí¶àÓ¦Óÿª·¢ÖÐ £¬ÎÒÃÇÐèÒª¶ÔͼƬ¾ÙÐд¦Àí £¬ÆäÖоÍÉæ¼°µ½Í¼Æ¬ÉÏ´«ºÍɾ³ý¡£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚ laravel ¿ò¼ÜÖÐɾ³ýÖ¸¶¨Ä¿Â¼ÏµÄͼƬ¡£

Ò»¡¢LaravelµÄÎļþ´æ´¢·½·¨

ÔÚ Laravel ¿ò¼ÜÖÐ £¬ÎÒÃÇ¿ÉÒÔͨ¹ý´æ´¢ÒýÇæÀ´¾ÙÐÐÎļþµÄ´æ´¢ºÍ²Ù×÷¡£Laravel ×Ô´øÁ˶àÖÖ´æ´¢ÒýÇæ £¬°üÀ¨£º

ÍâµØ´æ´¢ÒýÇ棨Local£©

Amazon S3 ´æ´¢ÒýÇ棨S3£©

RackSpace ´æ´¢ÒýÇ棨Rackspace£©

FTP ´æ´¢ÒýÇ棨FTP£©

Aliyun OSS ´æ´¢ÒýÇ棨OSS£©

ÔÚ±¾ÎÄÖÐ £¬ÎÒÃÇÖ÷ÒªÏÈÈÝÔõÑùÔÚÍâµØ´æ´¢ÒýÇæÖÐɾ³ýĿ¼ÖеÄͼƬ¡£

¶þ¡¢É¾³ýÍâµØ´æ´¢ÒýÇæÖеÄͼƬ

Ê×ÏÈ £¬ÎÒÃÇÐèÒªÔÚ Laravel ÖлñÈ¡´æ´¢Â·¾¶¡ £¿ÉÒÔͨ¹ý Storage::path() ÒªÁì»ñÈ¡ £¬ÀýÈ磺

$path = Storage::path('uploads/images/');

µÇ¼ºó¸´ÖÆ

½ÓÏÂÀ´ £¬ÐèҪȷ¶¨ÒªÉ¾³ýµÄͼƬÃû³Æ¡ £¿ÉÒÔͨ¹ý File::glob() ÒªÁì»ñȡĿ¼ÏÂËùÓÐÎļþ £¬È»ºó¾ÙÐйýÂË»ñÈ¡Ö¸ÃüÃûÌõÄÎļþ £¬ÀýÈ磺

$files = File::glob($path . '*.jpg');

µÇ¼ºó¸´ÖÆ

È»ºó £¬ÎÒÃÇ¿ÉÒÔÑ­»·±éÀúÕâЩͼƬ £¬Ê¹Óà File::delete() ÒªÁìɾ³ýÖ¸¶¨Í¼Æ¬ £¬ÀýÈ磺

foreach ($files as $file) {
    File::delete($file);
}

µÇ¼ºó¸´ÖÆ

Íê³ÉÒÔÉÏ°ì·¨ºó £¬ÎÒÃÇÒѾ­Íê³ÉÁËɾ³ýÖ¸¶¨Ä¿Â¼ÏÂËùÓÐÖ¸ÃüÃûÌõÄͼƬµÄ²Ù×÷¡£´úÂëʵÏÖÈçÏ£º

use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage;

$path = Storage::path('uploads/images/');
$files = File::glob($path . '*.jpg');
foreach ($files as $file) {
    File::delete($file);
}

µÇ¼ºó¸´ÖÆ

Èý¡¢×ܽá

±¾ÎÄÏÈÈÝÁËÔÚ Laravel ¿ò¼ÜÖÐɾ³ýÖ¸¶¨Ä¿Â¼ÏµÄͼƬµÄÒªÁ졣ͨ¹ýʹÓà Laravel ÌṩµÄÎļþ²Ù×÷ÒªÁì £¬ÎÒÃÇ¿ÉÒÔÈÝÒ×µØʵÏÖÎļþµÄɾ³ý²Ù×÷¡£Í¬Ê± £¬ÎÒÃÇÒ²¿ÉÒÔƾ֤ÏÖÕæÏàÐÎ £¬Ñ¡ÔñÆäËû´æ´¢ÒýÇæÀ´¾ÙÐÐÎļþµÄ²Ù×÷¡£Ï£Íû±¾ÎĶԸ÷ÈËÓÐËù×ÊÖú¡£

ÒÔÉϾÍÊÇlaravelÔõôɾ³ýĿ¼ÖеÄͼƬµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

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

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

QR code
ÍøÕ¾µØͼ