Professional Documents
Culture Documents
Bai 9
PHP nng cao
Ni dung
K thut Upload File bng PHP
K thut gi mail bng PHP S dng Cookie trong PHP
Ni dung
K thut Upload File bng PHP
K thut gi mail bng PHP S dng Cookie trong PHP
C ch Upload File
Yu cu trang upload.php Webserver
file
Internet or Intranet
Disk driver
--- UploadForm.htm --<form method="POST" action=upload.php enctype=multipart/form-data> <input type=FILE name =ProductImg><br> <input type=submit value=Submit"> </form>
"Upload: " . $_FILES["ProductImg"]["name"] . <br>; "Type: " . $_FILES["ProductImg"]["type"] . <br>; "Size: " . ($_FILES["ProductImg"]["size]/1024) . Kb<br>; Temp. Stored in: " . $_FILES["ProductImg"]["tmp_name"];
$_FILES[][size]
PHP Warning: move_uploaded_file(upload/14.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in.
Account IUSR_XXX
Ni dung
K thut Upload File bng PHP
K thut gi mail bng PHP S dng Cookie trong PHP
Ni dung
K thut Upload File bng PHP
K thut gi mail bng PHP S dng Cookie trong PHP
setcookie
Client Webserver
L 1 tp tin c server lu xung my ca client Mi ln client gi request 1 trang web, ng thi s gi km file cookie lu ln trc ln server Vic x l thng tin (lu, ly) trong cookie do server thc hin Thng c s dng lu thng tin c nhn ca client
2007 Khoa CNTT - HKHTN
name : Tn cookie value : Gi tr cookie expire : Thi im m cookie ht hiu lc path : ng dn trn server m cookie c hiu lc domain : Xc nh tn min m cookie c gi i Bt buc phi xut hin trc th <html>
Ly gi tr cookie
echo $_COOKIE[cookieName"];
Xa cookie
setcookie(cookieName", "", time() -3600);
Cookie V d
setcookie
Client Webserver
Ni dung
K thut Upload File bng PHP
K thut gi mail bng PHP S dng Cookie trong PHP
Session
$_SESSION[sessionVar] Cookie: PHPSESSID
session_start
Client Webserver
Hy c Session
session_destroy();
2007 Khoa CNTT - HKHTN
$_SESSION["count"] = $_SESSION["count"] + 1;
else $_SESSION["count"] = 1;
$_SESSION[Username]
: Lu Tn ng nhp
: Lu Loi quyn ng nhp
$_SESSION[Authentication]
V d: $_SESSION[IsLogin] = true. Lu : Phi t gi tr mc nh cho bin Session ny l false khi khi to mt Session.
{13, 2, 7}
Client 1
Session 2
Web Server
Session 3
Internet or Intranet
Client 2 Database Server
Cookie3
Client 3
S client Nhiu 1 1