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

laravel ÄÜÓÃftpÂð

laravel×÷Ϊһ¸öÏÖ´ú»¯µÄphp¿ª·¢¿ò¼Ü £¬¹ãÊÜ¿ª·¢ÕߵĽӴý¡£Ê¹ÓÃlaravel £¬¿ª·¢Õß¿ÉÒÔ¿ìËÙ¹¹½¨¿ÉÀ©Õ¹¡¢¸ßЧµÄwebÓ¦ÓóÌÐò¡£¿ÉÊÇ £¬ÓÐЩ¿ª·¢ÕßʹÓÃlaravelʱ¿ÉÄÜ»áÓöµ½ÐèҪʹÓÃftpµÄÇéÐÎ £¬ÄÇôlaravelÄÜ·ñʹÓÃftpÄØ£¿±¾ÎĽ«Îª¸÷È˽â´ðÕâ¸öÎÊÌâ¡£

Ê×ÏÈ £¬ÎÒÃÇÀ´ÏàʶһÏÂFTPÊÇʲô¡£FTPÊÇFile Transfer Protocol£¨Îļþ´«ÊäЭÒ飩µÄËõд £¬ËüÊÇÒ»ÖÖÓÃÓÚÔÚÍøÂçÉÏ´ÓÅÌËã»ú¼ä´«ÊäÎļþµÄ±ê×¼»¯Ð­Ò顣ʹÓÃFTP¿Í»§¶Ë¹¤¾ß £¬Äã¿ÉÒÔÅþÁ¬µ½Ô¶³ÌЧÀÍÆ÷ £¬²¢Í¨¹ýFTPЭÒéÉÏ´«¡¢ÏÂÔØÎļþ¡£ÄÇô £¬LaravelÄÜ·ñʹÓÃFTP¾ÙÐÐÎļþ´«ÊäÄØ£¿

ÃÕµ×ÊÇÒ»¶¨µÄ¡£LaravelÊÇÒ»¿îÎÞаµÄ¿ò¼Ü £¬ËüÖ§³Ö¶àÖÖÎļþϵͳ £¬°üÀ¨ÍâµØÎļþϵͳ¡¢Amazon S3ÔÆ´æ´¢¡¢FTPµÈµÈ¡£ÔÚLaravelÖÐ £¬¿ÉÒÔÖ±½ÓʹÓÃFTP¾ÙÐÐÎļþ´«Êä¡£

ÏÂÃæ £¬ÎÒÃÇÀ´¿´Ò»ÏÂÔõÑùÔÚLaravelÖÐʹÓÃFTP¡£

Ê×ÏÈ £¬ÔÚÏîÄ¿µÄ.envÎļþÖÐÌí¼ÓFTPÏà¹ØÉèÖÃÐÅÏ¢ £¬ÈçÏÂËùʾ£º

FTP_HOST=xxx.xxx.xxx.xxx
FTP_PORT=21
FTP_USERNAME=your_username
FTP_PASSWORD=your_password
FTP_ROOT=/path/to/ftp/root

µÇ¼ºó¸´ÖÆ

ÕâÀï £¬XXX.XXX.XXX.XXXÊÇFTPЧÀÍÆ÷µÄIPµØµã £¬21ÊÇFTPµÄ¶Ë¿ÚºÅ £¬your_usernameºÍyour_passwordÊÇFTPµÇ¼µÄÓû§ÃûºÍÃÜÂë £¬/path/to/ftp/rootÊÇFTPЧÀÍÆ÷µÄ¸ùĿ¼·¾¶¡£

È»ºó £¬ÔÚLaravelµÄÉèÖÃÎļþconfig/filesystems.phpÖÐÌí¼ÓFTPÇý¶¯ÉèÖà £¬ÈçÏÂËùʾ£º

'ftp' => [
    'driver'   => 'ftp',
    'host'     => env('FTP_HOST'),
    'port'     => env('FTP_PORT'),
    'username' => env('FTP_USERNAME'),
    'password' => env('FTP_PASSWORD'),
    'root'     => env('FTP_ROOT'),
],

µÇ¼ºó¸´ÖÆ

½ÓÏÂÀ´ £¬ÔÚLaravelÓ¦ÓóÌÐòÖÐʹÓÃFTPÎļþϵͳ £¬¿ÉÒÔʹÓÃÀàËÆÏÂÃæµÄ´úÂ룺

use IlluminateSupportFacadesStorage;

// ÉÏ´«Îļþµ½FTPЧÀÍÆ÷
Storage::disk('ftp')->put('file.txt', 'Hello World');

// ´ÓFTPЧÀÍÆ÷ÏÂÔØÎļþ
$contents = Storage::disk('ftp')->get('file.txt');

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄ´úÂëÖÐ £¬ÎÒÃÇͨ¹ýLaravelÄÚÖõÄStorageÃÅÃæÀ´²Ù×÷Îļþϵͳ £¬disk(‘ftp’)ÌåÏÖʹÓÃFTPÎļþϵͳÇý¶¯ £¬È»ºó¾Í¿ÉÒÔÏñ²Ù×÷ÍâµØÎļþϵͳһÑù²Ù×÷FTPÎļþ¡£

ÐèҪעÖصÄÊÇ £¬Ê¹ÓÃFTP¾ÙÐÐÎļþ´«ÊäÉÐÓÐһЩÇå¾²ÐÔÎÊÌâ £¬ºÃ±ÈFTP´«ÊäµÄÊý¾Ý²»¼ÓÃÜ £¬ÈÝÒ×±»ÖÐÑëÈ˹¥»÷Õß×èµ²ºÍÇÔÈ¡ £¬Òò´Ë½¨ÒéʹÓÃSFTP£¨Secure File Transfer Protocol £¬Çå¾²Îļþ´«ÊäЭÒ飩»òFTPES£¨FTP over Explicit SSL/TLS £¬Ã÷È·Çå¾²Ì×½Ó²ãµÄFTP£©µÈÇå¾²µÄЭÒé¾ÙÐÐÎļþ´«Êä¡£

×ÛÉÏËùÊö £¬LaravelÖÐÍêÈ«¿ÉÒÔʹÓÃFTP¾ÙÐÐÎļþ´«Êä £¬¿ª·¢ÕßÖ»ÐèÒªÔÚ.envÎļþÖÐÉèÖÃFTPÏà¹ØµÄÐÅÏ¢ £¬²¢ÔÚconfig/filesystems.phpÖÐÌí¼ÓFTPÇý¶¯ÉèÖà £¬¾Í¿ÉÒÔÇáËɵØʹÓÃFTP¾ÙÐÐÎļþ´«ÊäÁË¡£ËäÈ» £¬ÎªÁË°ü¹ÜÇå¾²ÐÔ £¬½¨ÒéÔÚÏÖʵʹÓÃʱ½ÓÄÉÔ½·¢Çå¾²µÄЭÒé¡£

ÒÔÉϾÍÊÇlaravel ÄÜÓÃftpÂðµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

QR code
ÍøÕ¾µØͼ