douchongzhang9267 2018-06-03 07:15
浏览 29

MySQL BLOB只接受图像吗?

Does MySQL BLOB only accept images?

I have been looking online trying to be able to upload larger file sizes of different formats, but I only come across image tutorials.

I have the code below, which fails on the if statement and returns the echo when I upload different file types larger than 10 megs. (the column is LONGBLOB).

ini_set('error_reporting', E_ALL);
ini_set('display_errors', 'On');  //On or Off


         $file = rand(1000,100000)."-".$_FILES['file']['name'];
         $notes = mysqli_real_escape_string($connection,$_POST['notes']);
         $file_loc = $_FILES['file']['tmp_name'];
         $file_size = $_FILES['file']['size'];
         $file_type = $_FILES['file']['type'];

         $email = mysqli_real_escape_string($connection, $_SESSION['email']);


            $sql = "INSERT INTO `supportcontent` (`scontentdata`, `scontentnotes`, `suseremail`, `stype`,`ssize`)
            VALUES( '$file','$notes','$email','$file_type ','$file_size')";

            $current_id = mysqli_query($connection, $sql) 
            or die("<b>Error:</b> Problem on Image Insert<br/>" . mysqli_error($connection));
            if (isset($current_id)) {
                header("Location: landingpage.php?upload=success");
            echo 'file is 0';
  • 写回答

2条回答 默认 最新

  • duanchen1937 2018-06-03 07:39

    Does MySQL BLOB only accept images?

    No, you can store anything you want in it. What's failing when you try to upload a file over 10MB is not the SQL, but the PHP code. Either:

    1. the files size limit. Check the value of the upload_max_filesize and post_max_size settings in the php.ini file.

    2. or the operation timing out. This is more likely to be the culprit especially if you've never changed the default values in your php.ini file. The default timeout in PHP is 30 seconds, so your file must be uploaded in less than 30 seconds. You can change it in the php.ini file using the max_execution_time setting, or it is better to change it in you code using the set_time_limit() function.

    Example, to set the timeout to 2 minutes:

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥15 vhdl+MODELSIM
  • ¥20 simulink中怎么使用solve函数?
  • ¥30 dspbuilder中使用signalcompiler时报错Error during compilation: Fitter failed,求解决办法
  • ¥15 gwas 分析-数据质控之过滤稀有突变中出现的问题
  • ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
  • ¥15 知识蒸馏实战博客问题
  • ¥15 用PLC设计纸袋糊底机送料系统
  • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
  • ¥15 用C语言输入方程怎么
  • ¥15 网站显示不安全连接问题