donglunzai4288 2016-09-17 15:08
浏览 19

UserSpice文件上传有MySQL下载链接

I am trying to use UserSpice to make an address book with a upload part that will be used to upload a CV and stored under the profile that is being created.

I got the file to upload, but I cant get it to add the data to the users table but if I make a different table it works, can anybody help me solve this?

The Form

<form action="<?=$form_action;?>" method="<?=$form_method;?>" enctype="multipart/form-data">
<input type="file" name="file" />
<button type="submit" id="next_button" name="submit"><?=lang("SIGNUP_BUTTONTEXT","");?></button>

The post script

<?php
include_once 'dbconfig.php';
if(isset($_POST['submit']))
{

$file = rand(1000,100000)."-".$_FILES['file']['name'];
$file_loc = $_FILES['file']['tmp_name'];
$file_size = $_FILES['file']['size'];
$file_type = $_FILES['file']['type'];
$folder="cvs/";


$new_size = $file_size/1024;
$new_file_name = strtolower($file);
$final_file=str_replace(' ','-',$new_file_name);

if(move_uploaded_file($file_loc,$folder.$final_file))
{
$sql="INSERT INTO users(file,type,size) VALUES('$final_file','$file_type','$new_size')";
mysql_query($sql);
?>

Added to Users Table

`file` VARCHAR( 100 ) NOT NULL ,
`type` VARCHAR( 10 ) NOT NULL ,
`size` INT NOT NULL
  • 写回答

1条回答 默认 最新

  • duangu8264 2016-09-17 17:04
    关注

    Your new size is very likely to be a decimal, not an int:

    $new_size = $file_size/1024;
    

    You want to get the whole number to insert into an Int field.

    $new_size = floor($file_size/1024);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)