-
Notifications
You must be signed in to change notification settings - Fork 0
/
heads_update_file.php
39 lines (38 loc) · 1.23 KB
/
heads_update_file.php
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
<?php
session_start();
if(empty($_SESSION['loginuser'])){
die("error");
}
require_once './model/usersService.class.php';
if ((($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br />";
}
else
{
/*echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Stored in: " . $_FILES["file"]["tmp_name"];
echo "<br/>";*/
$userv= new usersService();
$_FILES["file"]["name"]=$_SESSION['loginuser'].".jpg";
$url="images/userheads/" . $_FILES["file"]["name"];
$b=$userv->setHeadsUrl($_SESSION['loginuser'],$url);
if($b==0){
die("修改头像失败");
}
move_uploaded_file($_FILES["file"]["tmp_name"],
"images/userheads/" . $_FILES["file"]["name"]);
//echo "images/userheads/" . $_FILES["file"]["name"];
header("Location:./account/index.php?msg=1");
}
}
else
{
header("Location:./account/index.php?msg=2");
}