۳ rahnama
فرمت فایل نا مناسب
جامعه پی اچ پی ایجاد شده در ۲۶ اسفند ۱۴۰۱

درشرط تابع in _array با اینکه فرمت فایل رو تعیین کردم ،پیام your file is not supported نمایش میده

چند فایل مختلف رو امتحان کردم ولی باز همینه

$fileExtention = strtolower(end($fileNameSperator));
               $newNameFile = md5(time().$nameFile).'.'.$fileNameExtention;
               $allowedFilesExtentions=['jpg','png','gif','zip','ico','rar','txt'];
               if (in_array($fileExtention,$allowedFilesExtentions)) {
                      $newDirectori ='uploaded/';
                      $despath = $newDirectori.$newNameFile;
                      if (move_uploaded_file($TmpNameFile,$despath)) {
                    $msg = 'your file uploaded successfully';
                    }else {
                        $msg = 'your file uploaded  not successfully!!!';
                      }
                 } 
               else {
               $msg = 'your file is not supported' ;
               }

این هم کاملش

session_start();
$msg = null;
    if ($_SERVER['REQUEST_METHOD']=="POST") 
    {
        if (isset($_POST['uploadBtn']) && $_POST['uploadBtn']== 'upload') 
        {
            if (isset($_FILES["file-upload"]) && !empty($_FILES["file-upload"])) 
            {
                 $nameFile = $_FILES["file-upload"]['name'].'
'
;                  $typeFile = $_FILES["file-upload"]['type'].'
'
;                  $sizeFile = $_FILES["file-upload"]['size'].'
'
;                 $TmpNameFile = $_FILES["file-upload"]['tmp_name'].'
'
;                 $fileNameSperator = explode('.',$nameFile);                  $fileExtention = strtolower(end($fileNameSperator));                $newNameFile = md5(time().$nameFile).'.'.$fileNameExtention;                $allowedFilesExtentions=['jpg','png','gif','zip','ico','rar','txt'];                if (in_array($fileExtention,$allowedFilesExtentions)) {                 $newDirectori ='uploaded/';                 $despath = $newDirectori.$newNameFile;                 if (move_uploaded_file($TmpNameFile,$despath)) {                     $msg = 'your file uploaded successfully';                 }else {                     $msg = 'your file uploaded  not successfully!!!';                   }                }                          else {                $msg = 'your file is not supported' ;                }             }             else             {                 $msg='pleasse select your file to upload';             }         }     }; $_SESSION['msg']= $msg; header("location:index.php"); ?>
rahnama ۲۶ اسفند ۱۴۰۱، ۱۰:۵۱

مشکل حل شد

متوجه اشتباهم شدم ?

rahnama ۲۶ اسفند ۱۴۰۱، ۱۰:۵۴

سلام محمد عزیز

سینگل کت‌ها رو از انتهای متغیرهایی که سوپرگلوبال files رو استفاده کردید بردارید.

بهترین پاسخ
احمدرضا فاطمی کیا ۲۶ اسفند ۱۴۰۱، ۱۰:۵۸