i want to upload file on folder upload and save the link on my table under name Link1. it keep give me error on upload side. can anybody tell me where is the wrong in my code, i do not want use upload.php i want all my work to be at the same page. thank you.
<?php
include 'db_connection.php';
if(isset($_POST['finish'])){
$file_name = $_FILES['link1']['name'];
$file_size =$_FILES['link1']['size'];
$file_tmp =$_FILES['link1']['tmp_name'];
$file_type=$_FILES['link1']['type'];
move_uploaded_file($file_tmp,"uploads/".$file_name);
$name = '"'.$dbConnection->real_escape_string($_POST['name']).'"';
$Mobile = '"'.$dbConnection->real_escape_string($_POST['Mobile']).'"';
$civilid = '"'.$dbConnection->real_escape_string($_POST['civilid']).'"';
$bulildingnumber = '"'.$dbConnection->real_escape_string($_POST['bulildingnumber']).'"';
$province = '"'.$dbConnection->real_escape_string($_POST['province']).'"';
$area = '"'.$dbConnection->real_escape_string($_POST['area']).'"';
$block = '"'.$dbConnection->real_escape_string($_POST['block']).'"';
$house = '"'.$dbConnection->real_escape_string($_POST['house']).'"';
$contractdata = '"'.$dbConnection->real_escape_string($_POST['contractdata']).'"';
$projecttype = '"'.$dbConnection->real_escape_string($_POST['projecttype']).'"';
$link1 = '"'.$dbConnection->real_escape_string($_POST[$file_name]).'"';
$sqlInsertUser = $dbConnection->query("INSERT INTO users (name, Mobile, civilid, bulildingnumber,area,block,house,contractdata, projecttype,province,Link1) VALUES($name, $Mobile, $civilid, $bulildingnumber,$area,$block,$house,$contractdata, $projecttype,$province,$link1)");
if($sqlInsertUser === false){
$message = 'Error: ' . $dbConnection->error;
}else{
$message = 'Last inserted record is : ' .$dbConnection->insert_id ;
}
}
?>
here is my HTML code to pick the file
<label>Decumnets needed</label>
<div><input type="file" name="link1" id="link1" class="InputBox" /></div>
Aucun commentaire:
Enregistrer un commentaire