Skip to content

Commit

Permalink
update for database connection and update database
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishi Vishwakarma committed Nov 26, 2015
1 parent 455b995 commit 7f12e95
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ajax/ajax_php_file.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
$sourcePath = $_FILES['file']['tmp_name']; // Storing source path of the file in a variable
$targetPath = "../upload/" . $_FILES['file']['name']; // Target path where file is to be stored
move_uploaded_file($sourcePath, $targetPath); // Moving Uploaded file

// replace $host,$username,$password,$dbname with real info
$dbh=mysqli_connect($host,$username,$password,$dbname);
mysqli_query($dbh,"INSERT INTO `files` (filename,path) VALUES ('".$_FILES['uploaded_file']['tmp_name']."','".$file_path."')") or trigger_error($link->error."[ $sql]");
mysqli_close($dbh);

echo "<span id='success'>Image Uploaded Successfully...!!</span><br/>";
echo "<br/><b>File Name:</b> " . $_FILES["file"]["name"] . "<br>";
echo "<b>Type:</b> " . $_FILES["file"]["type"] . "<br>";
Expand Down

0 comments on commit 7f12e95

Please sign in to comment.