|
 |
|
พี่ ๆทุกคน พี่ phpbasic คะ พี่ num พี่ p@e และพี่ที่น่ารักทุกคนช่วยที |
|
 |
|
|
 |
 |
|
ตรง input
function plus(){
if (n>=5){
return;
}
if (w==1) { plusnormal(); }
if (w==2 && n<5){ plusremote(); }
}
..........................
ส่วนตรง upload type กับ upload size (ยังไม่ได้ลองนะครับ หวังว่าจะใช้ได้นะ)
<?php
function extIs($file_name,$ext){
$file_ext=strtolower(substr(strrchr($file_name,'.'),1));
return in_array($file_ext,$ext,true);
}
$EXT = array('jpg','jpeg');
$MAX_SIZE = 2*1024*1024; //2M
$err = '';
foreach($_FILES as $name => $file){
if ($file['size']>$MAX_SIZE){
$err .= "\nFILE SIZE ERROR";
}
if (!extIs($file['name'],$EXT)){
$err .= "\nFILE EXTENSION ERROR";
}
}
if (empty($err)){
echo 'no error';
}else{
echo 'has error:',nl2br($err);
}
?>
|
 |
 |
 |
 |
Date :
2009-08-29 21:40:33 |
By :
num |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบพระคุณมากค่ะพี่ num แล้วจะมารายงานผลนะคะ
|
 |
 |
 |
 |
Date :
2009-08-30 09:45:53 |
By :
gigza |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พี่ num คะ ตรง input กำหนดได้แล้วค่ะ ขอบคุณมากนะคะ
แต่
<?php
function extIs($file_name,$ext){
$file_ext=strtolower(substr(strrchr($file_name,'.'),1));
return in_array($file_ext,$ext,true);
}
$EXT = array('jpg','jpeg');
$MAX_SIZE = 2*1024*1024; //2M
$err = '';
foreach($_FILES as $name => $file){
if ($file['size']>$MAX_SIZE){
$err .= "\nFILE SIZE ERROR";
}
if (!extIs($file['name'],$EXT)){
$err .= "\nFILE EXTENSION ERROR";
}
}
if (empty($err)){
echo 'no error';
}else{
echo 'has error:',nl2br($err);
}
?>
มีคำถามเพิ่มเติมค่ะ ว่าเราจะไว้ตรงส่วนไหนคะ ของโปรแกรม และ
1. นอกจาก $EXT = array('jpg','jpeg'); เราสามารถเพิ่มเป็นนามสกุลต่อไปได้เลยหรือเปล่า
2. $file['size'] ตัวนี้คือตัวบอกค่าของขนาดไฟล์ใช่มั้ยคะ
|
 |
 |
 |
 |
Date :
2009-08-30 09:52:17 |
By :
gigza |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|