|
 |
|
อยากถามนิดหน่อยครับ ผมทำ upload ไฟล์ ทีนี้จะแยก type ของไฟล์ ออกจากกัน |
|
 |
|
|
 |
 |
|
Code (PHP)
$exd_date=explode(".","sek.jpg");
$n=$exd_date[0];
$t=$exd_date[1];
echo $n."<br>";
echo $t."<br>";
|
 |
 |
 |
 |
Date :
2009-10-22 16:18:20 |
By :
Sek-Artdrinker |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณหลายเด้ออ้ายเสก
เมื่อกี้ผลลองใช้ split ก็ได้เหมือนกันครับ
Code (PHP)
$filename = "xxx.jpg";
$filename2 = split('[.]', $filename);
echo $filename2[0];
echo $filename2[1];
|
 |
 |
 |
 |
Date :
2009-10-22 16:24:03 |
By :
ICrazyMan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
strtolower(end(explode('.',$fileupload_name)));
มีปัญหานิดหน่อยตรงชื่อไฟล์ที่ไม่มี extension ครับ อย่างเช่น test
<?php
function file_ext($fname){
return strtolower(substr(strrchr($fname,'.'),1));
}
function file_name($fname){
$ext = file_ext($fname);
return empty($ext) ? $fname : substr($fname,0, -strlen($ext)-1);
}
$fname = 'testddd.jpg';
echo '<br><br>filename: ',$fname;
echo '<br>ext: ',file_ext($fname);
echo '<br>name: ',file_name($fname);
$fname = 'testddd';
echo '<br><br>filename: ',$fname;
echo '<br>ext: ',file_ext($fname);
echo '<br>name: ',file_name($fname);
split หรือ explode ก็ยัมีปัญหากับชื่อไฟล์อย่างเช่น test.test2.jpg ครับ
|
 |
 |
 |
 |
Date :
2009-10-22 16:27:02 |
By :
num |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อ๋อ ครับ
|
 |
 |
 |
 |
Date :
2009-10-22 16:35:49 |
By :
ICrazyMan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|