-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuploadimage.php
More file actions
42 lines (36 loc) · 1.14 KB
/
Copy pathuploadimage.php
File metadata and controls
42 lines (36 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
session_start();
$username=$_SESSION['username'];
error_reporting(0);
mysql_connect("localhost","root","");
mysql_select_db($username);
if(isset($_POST['submit']))
{
$target_dir = $username."/";
$target_file = $target_dir . basename($_FILES["file"]["name"]);
$name=$_FILES['file']['name'];
$temp=$_FILES['file']['tmp_name'];
$image_size = $_FILES['file']['size'];
$image_type = pathinfo($target_file,PATHINFO_EXTENSION);
move_uploaded_file($temp,$target_dir.$name);
$image_path=$username."/".$name;
mysql_query("INSERT INTO $username.`images` (`image_id`,`image`, `image_type`, `image_size`,`image_path`) VALUES (NULL,'".$name."', '".$image_type."','".$image_size."','".$image_path."');");
}
?>
<!DOCTYPE html>
<html>
<body>
<a href="viewimage.php">Images</a>
<form enctype="multipart/form-data" action="uploadimage.php" method="post">
Browse for File to Upolad: <br>
<input name="file" type="file" id="file" size="80"><br>
<input type="submit" name="submit" value="Upload ">
</form>
<?php
if(isset($_POST['submit']))
{
echo "<br />".$name."has been uploaded";
}
?>
</body>
</html>