Chuyên đề CSDL và WEB– Bài 9 : PHP và File, Session, Cookies, Mail
© 2009 Khoa CNTT - ĐHKHTN
V
Ví
íd
d
Chuyên đề CSDL và WEB– Bài 9 : PHP và File, Session, Cookies, Mail
© 2009 Khoa CNTT - ĐHKHTN
3.
3. Di
Di chuy
chuy
n
nt
t
p
ptin
tin t
t
th
thư
ưm
m
c
ct
t
m
msang
sang th
thư
ưm
m
c
cupload
upload
move_uploaded_file (tmp_name, saved_name)
Chuyên đề CSDL và WEB– Bài 9 : PHP và File, Session, Cookies, Mail
© 2009 Khoa CNTT - ĐHKHTN
Ki
Ki
m tra l
m tra l
i,
i, đ
đ
nh d
nh d
ng, k
ng, kí
ích thư
ch thư
c File upload
c File upload
Lư :
$_FILES["…"]["type"]
"image/gif"
"image/jpeg" ÆFirefox nhnđây file jpeg
"image/pjpeg" ÆIE nhnđây file jpeg
$_FILES["…"]["size"] : Kích thước file tính theo byte
$_FILES["…"]["error"] : Mã li khi upload File
= 0 : Không li
> 0 : Có li
Chuyên đề CSDL và WEB– Bài 9 : PHP và File, Session, Cookies, Mail
© 2009 Khoa CNTT - ĐHKHTN
M
M
t
ts
s
l
l
i
ikhi
khi upload file
upload file
li Hng sÝ nghĩa
0UPLOAD_ERR_OK There is no error
1UPLOAD_ERR_INI_SIZE The uploaded file exceeds the
upload_max_filesize directive in
php.ini
2UPLOAD_ERR_FORM_SIZE The uploaded file exceeds the
MAX_FILE_SIZE directive that
was specified in the HTML form
3UPLOAD_ERR_PARTIAL The uploaded file was only
partially uploaded
4UPLOAD_ERR_NO_FILE No file was uploaded
6UPLOAD_ERR_NO_TMP_DIR Missing a temporary folder
7UPLOAD_ERR_CANT_WRITE Failed to write file to disk
Chuyên đề CSDL và WEB– Bài 9 : PHP và File, Session, Cookies, Mail
© 2009 Khoa CNTT - ĐHKHTN
V
V
n
nđ
đ
v
v
quy
quy
n
ntruy
truy c
c
p
pFile
File
PHP Warning:
move_uploaded_file(upload/14.jpg
) [function.move-uploaded-file]:
failed to open stream:
Permission denied in.
Account
IUSR_XXX
Lư :
Chcp quyn ghi cho thưmccnthiết
Không cpquyn ghi cho thưmc
WebRoot