Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/245.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php mysql blob上传返回500_Php_Mysql - Fatal编程技术网

Php mysql blob上传返回500

Php mysql blob上传返回500,php,mysql,Php,Mysql,对不起,如果我在这里输入的代码太长。长句短句。我想提交一个具有不同字段和图像字段的表单。当我在localhost上运行时,它工作正常,它验证图像文件和所有其他字段 但是,当我FTP到服务器时,如果我将一个随机文件放入图像字段,并将其余字段留空,然后我将其提交,它不会进行验证,并在几秒钟后打印出500个错误代码。有人知道发生了什么吗 <!--//Checking field + submitting form--> <?php if(empty($_POST) === fal

对不起,如果我在这里输入的代码太长。长句短句。我想提交一个具有不同字段和图像字段的表单。当我在localhost上运行时,它工作正常,它验证图像文件和所有其他字段

但是,当我FTP到服务器时,如果我将一个随机文件放入图像字段,并将其余字段留空,然后我将其提交,它不会进行验证,并在几秒钟后打印出500个错误代码。有人知道发生了什么吗

<!--//Checking field + submitting form-->
<?php  
if(empty($_POST) === false)
{
$requiredField = array('title', 'price', 'description');
foreach($_POST as $key=>$value)
{
   if(empty($value) && in_array($key, $requiredField) === true)
   {
       $error[] = $allFieldsAreRequired;
       break 1;
   }
}

//validation form
if(strlen($_POST['title']) > 70 || strlen($_POST['title']) < 6)
{
    $error[] = $titleInvalid; 
}

if(!validation_numberOnly($_POST['price']))
{
    $error[] = $priceInvalid; 
}

$file = $_FILES['file']['tmp_name'];
$image = '';
$image_type = '';

if(!empty($_FILES['file']['name']))
{
    //addslashes prevent sql injection
   $image = addslashes(file_get_contents($_FILES['file']['tmp_name']));
   $image_name = addslashes($_FILES['file']['name']);
   $image_size = getimagesize($_FILES['file']['tmp_name']);
   $image_type = $image_size['mime'];     

   if($image_size == false)
   {
       $error[] = "File is not a image file"; 
   }

   if(filesize($file) > 400000)
   {
       $error[] = 'File is too big, we only accept 400kb';
   }
}

//if success no errors, submit
if(empty($error) === true)
{
    $product_data = array(
        'title'             => $_POST['title'],
        'price'             => $_POST['price'],
        'category'          => $_POST['categories'],
        'description'       => $_POST['description'],
        'owner'             => $user_data['username'],
        'upload_date'       => date("Y-m-d H:i"),
    );

    $product_image = array(
        'imageData'             => $image,
        'imageType'        => $image_type,
    );

    add_new_products($product_data, $product_image) ? header('Location: successful.php') : header($ErrorPageLocation);
    exit();
   }
   }
   ?>

   <div class="well">
   <form class="form-horizontal form-max-size" action='' method="POST"
      enctype="multipart/form-data">

     <div class="form-group">
<label for="inputEmail3" class="col-sm-1 control-label">Title*</label>
<div class="col-sm-10">
     <input type="text" id="title" class="form-control max-input-width-2" name="title" placeholder="e.g: Iphone5s white 16GB for sale..." value="<?php is_data_field_set('title');  ?>">
</div>

头衔*
形象
出版

对于web服务器中的每一个错误,第一件事就是检查错误日志。我认为这个页面还没有到那个程度。它应该首先验证字段,不是吗?无错误500响应是一个响应。这意味着服务器收到了您的请求并回答了一些问题。500表示出现了问题,您必须查看日志以获取更详细的信息。我在这里没有看到任何与cakephp相关的内容,标记是否错误,或者您是否使用了cake,并且没有包含任何引用它的代码?
   <div class="form-group">
   <label for="inputPassword3" class="col-sm-1 control-label">Price (£, GBP)*</label>
   <div class="col-sm-10">
    <input type="text" class="form-control max-input-width-2" id="price" name="price" placeholder=""
                               value="<?php is_data_field_set('price');  ?>">
       </div>
     </div>


     <div class="form-group">
<label class="col-sm-1 control-label">Categories*</label>
<div class="col-sm-10">
        <select name="categories">
            <?php
            //print all categories
            $all_categories = retrieve_product_categories();
            for($i=0; $i<sizeof($all_categories); $i++)
            {
                echo '<option value='.$all_categories[$i]['category_id'].'>'. $all_categories[$i]['category_full_name'] . '</option>';
            }
            ?>
        </select>    </div>
     </div>


       <div class="form-group">
       <label for="inputPassword3" class="col-sm-1 control-label">Image</label>
       <div class="col-sm-10">
     <input type="file" name="file" class="form-control max-input-width-2" id="file">
       </div>
     </div>   

     <div class="form-group">
<div class="col-sm-offset-1 col-sm-10">
   <button class="btn btn-success" type="submit">Publish</button>
</div>
     </div>
   </form>
   </div>