Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form action="/Alesh_New_Website/saveImg.php" method="POST" enctype="multipart/form-data">
- <input type="file" name="image">
- <input type="submit" name="submit" value="Upload">
- </form>
- $servername = "localhost";
- $username = "root";
- $password = "root";
- $dbname = "IMGSTORAGE";
- try{
- $conn = new PDO("mysql:host=$servername; dbname=$dbname", $username, $password);
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $name = addslashes($_FILES['image']['name']);
- $image = addslashes($_FILES['name']['tmp_name']);
- $image = file_get_contents($image);
- $image = base64_encode($image);
- $sql = "INSERT INTO 'STOREDIMG' ('name', 'image') VALUES ('$name, $image')";
- $conn->exec($sql);
- echo "Image uploaded";
- }
- catch (PDOException $e){
- echo "Connection Failed: " . $e->getMessage();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement