Unable to do File Upload in PHP

前端 未结 3 1394
离开以前
离开以前 2020-12-22 02:20

I want to upload files in PHP. I wrote

3条回答
  •  情书的邮戳
    2020-12-22 03:09

    You are a long way from a working script

    You can try

     800*1024) {
            $errors [] = "File Too large";
        }
    
        if (! is_writable ( $savePath )) {
            $errors [] = "File Destination not writeable";
        }
    
        $fileDst = $savePath . DIRECTORY_SEPARATOR . $fileName;
        $filePrifix = basename ( $fileName, "." . $fileExt );
        $i = 0;
        while ( file_exists ( $fileDst ) ) {
            $i ++;
            $fileDst = $savePath . DIRECTORY_SEPARATOR . $filePrifix . "_" . $i . "." . $fileExt;
    
        }
        if (count ( $errors ) == 0) {
            if (@move_uploaded_file ( $fileTemp, $fileDst )) {
                $output['STATUS'] = "OK";
                $output['TYPE'] = $fileType;
                $output['Size'] = $fileSize;
                $output['Destination'] = $fileDst;
            } else {
                $errors [] = "Error Saving File";
            }
    
        }
    
    
        if(count($errors) > 0)
        {
            echo "

    Upload Error

    " ; foreach ($errors as $error) { echo $error , "
    " ; } } else { echo "

    File Uploaded

    " ; foreach ($output as $key => $value) { echo $key , ":" , $value , "
    " ; } } } ?>

提交回复
热议问题