尊龙凯时人生就是搏

thinkphpʵÏÖ±íµ¥ÉÏ´«¸½¼þ

ÔÚweb¿ª·¢ÖУ¬±íµ¥µÄÉÏ´«¸½¼þ¹¦Ð§ÊǷǾ­³£¼ûµÄ£¬Õâ¸ö¹¦Ð§Äܹ»ÈÃÓû§Àû±ãµØÉÏ´«×Ô¼ºËùÐèÒªµÄÎļþ£¬ºÃ±ÈͼƬ¡¢Îĵµ¡¢ÒôƵµÈµÈ¡£¶øÔÚphpÓïÑÔÖУ¬¿ÉÒÔʹÓÃthinkphp¿ò¼ÜÀ´ÊµÏÖ±íµ¥ÉÏ´«¸½¼þµÄ¹¦Ð§¡£ÏÂÃæÎÒÃÇÀ´Ò»²½Ò»²½µØѧϰÔõÑùʹÓÃthinkphpʵÏÖ±íµ¥ÉÏ´«¸½¼þ¡£

Ò»¡¢ÇéÐÎ×¼±¸

ÔÚʹÓÃthinkphp¿ò¼Ü֮ǰ£¬ÎÒÃÇÐèÒªÏȴһ¸öÊʵ±µÄÔËÐÐÇéÐΡ£ÏêϸµÄ°ì·¨ÈçÏ£º

×°ÖÃphpÇéÐÎ

×°ÖÃcomposer

н¨Ò»¸öthinkphpÏîÄ¿

ÉèÖÃÊý¾Ý¿âºÍ·ÓÉ

×°ÖÃÐëÒªµÄÀ©Õ¹¿â

¶þ¡¢½¨ÉèÉÏ´«±íµ¥

ÔÚthinkphp¿ò¼ÜÖУ¬¿ÉÒÔʹÓÃform±íµ¥ÌìÉúÆ÷À´¿ìËÙÌìÉúÒ»¸öÉÏ´«±íµ¥¡£ÏêϸʵÏÖ°ì·¨ÈçÏ£º

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»

½¨ÉèÒ»¸öÃûΪuploadµÄ¿ØÖÆÆ÷£¬ÔڸÿØÖÆÆ÷ÖУ¬Ìí¼ÓÒ»¸öindexÒªÁì¡£

namespace appindexcontroller;

use thinkController;

class Upload extends Controller
{
    public function index()
    {
        return $this->fetch();
    }
}

µÇ¼ºó¸´ÖÆ

ÔÚviewÎļþ¼ÐÖÐн¨Ò»¸öupload.htmlÎļþ¡£

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Upload</title>
</head>
<body>
    <form action="" method="post" enctype="multipart/form-data">
        <input type="file" name="file">
        <input type="submit" value="ÉÏ´«">
    </form>
</body>
</html>

µÇ¼ºó¸´ÖÆ

ÒÔÉÏ´úÂë»áÌìÉúÒ»¸ö°üÀ¨ÎļþÉÏ´«¹¦Ð§µÄ±íµ¥£¬ÆäÖÐinput±êÇ©µÄnameÊôÐÔΪfile£¬¼´ÉÏ´«ÎļþµÄÃû³Æ¡£

Èý¡¢´¦ÀíÉÏ´«Îļþ

µ±Óû§µã»÷ÉÏ´«°´Å¥²¢Ñ¡ÔñÁËÉÏ´«Îļþºó£¬ÎÒÃǾÍÐèÒª½«ÉÏ´«µÄÎļþÉúÑĵ½Ö¸¶¨µÄλÖá£Õâ¸ö¹¦Ð§ÐèÒªÔÚ¿ØÖÆÆ÷ÖÐʵÏÖ£¬Ïêϸ°ì·¨ÈçÏ£º

ÐÞ¸Äupload.htmlµÄform±íµ¥actionÊôÐÔΪupload/uploadFile¡£

<form action="upload/uploadFile" method="post" enctype="multipart/form-data">

µÇ¼ºó¸´ÖÆ

ÔÚupload¿ØÖÆÆ÷ÖÐÌí¼ÓuploadFileÒªÁ죬¸ÃÒªÌå»á½«ÉÏ´«ÎļþÉúÑĵ½Ö¸¶¨µÄλÖò¢·µ»ØÉÏ´«ÎļþµÄÐÅÏ¢¡£ÓÉÓÚthinkphp¿ò¼Ü×Ô´øÁËÎļþÉÏ´«À࣬ÎÒÃÇ¿ÉÒÔÖ±½ÓʹÓøÃÀàÀ´Íê³ÉÎļþÉÏ´«µÄ¹¦Ð§¡£

public function uploadFile()
{
    $file = request()->file('file');

    $info = $file->move(ROOT_PATH . 'public' . DS . 'uploads');

    if ($info) {
        return 'ÎļþÉÏ´«Àֳɣº' . $info->getSaveName();
    } else {
        return $file->getError();
    }
}

µÇ¼ºó¸´ÖÆ

ÒÔÉÏ´úÂë¿ÉÒÔ»ñÈ¡µ½ÉÏ´«µÄÎļþ¹¤¾ß£¬È»ºóʹÓÃÎļþÉÏ´«ÀàÀ´ÉúÑÄÎļþµ½Ö¸¶¨µÄλÖá£ÈôÊÇÉÏ´«Àֳɣ¬Ôò·µ»ØÉÏ´«ÎļþµÄÐÅÏ¢£»²»È»¾Í·µ»ØÉÏ´«¹ýʧÐÅÏ¢¡£

ÔÚÍê³ÉÒÔÉÏ°ì·¨ºó£¬ÎÒÃǵÄÉÏ´«¸½¼þ¹¦Ð§¾ÍÍê³ÉÁË¡£Óû§¿ÉÒÔͨ¹ýÉÏ´«±íµ¥ÇáËɵØÉÏ´«×Ô¼ºµÄÎļþÁË¡£

×ܽá

ÔÚ±¾ÎÄÖУ¬ÎÒÃÇʹÓÃthinkphp¿ò¼ÜÀ´ÊµÏÖÁË±íµ¥ÉÏ´«¸½¼þµÄ¹¦Ð§¡£Õâ¸öʵÏÖ°ì·¨½ÏÁ¿¼òÆÓ£¬Ö»ÐèҪƾ֤ÉÏÊö°ì·¨Ò»²½Ò»²½µØÍê³É¼´¿É¡£ÖµµÃ×¢ÖصÄÊÇ£¬thinkphp¿ò¼ÜÌṩÁ˺ÜÊǸ»ºñµÄ¹¦Ð§ºÍÀà¿â£¬ÉîÈëѧϰthinkphp¿ò¼Ü¿ÉÒÔÈÃÎÒÃÇÔÚweb¿ª·¢ÖÐÔ½·¢¸ßЧµØÍê³ÉʹÃü¡£

ÒÔÉϾÍÊÇthinkphpʵÏÖ±íµ¥ÉÏ´«¸½¼þµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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