回答
http://codeigniter.com/user_guide/libraries/file_uploading.html
$this->upload->data()
這是一個輔助函數返回一個包含所有涉及到你上傳的文件中的數據的數組。這裏是數組原型:用戶上傳的東西
所以經過Array
(
[file_name] => mypic.jpg
[file_type] => image/jpeg
[file_path] => /path/to/your/upload/
[full_path] => /path/to/your/upload/jpg.jpg
[raw_name] => mypic
[orig_name] => mypic.jpg
[client_name] => mypic.jpg
[file_ext] => .jpg
[file_size] => 22.2
[is_image] => 1
[image_width] => 800
[image_height] => 600
[image_type] => jpeg
[image_size_str] => width="800" height="200"
)
,你可能想在你的數據庫文件的擴展名與有關圖像的其他詳細信息存儲:-)
$name_of_file_with_extn = $this->upload->data('file_name')
你可將商品的名字從名單如下改變
file_name Name of the file that was uploaded, including the filename extension file_type File MIME type identifier file_path Absolute server path to the file full_path Absolute server path, including the file name raw_name File name, without the extension orig_name Original file name. This is only useful if you use the encrypted name option. client_name File name as supplied by the client user agent, prior to any file name preparation or incrementing file_ext Filename extension, period included file_size File size in kilobytes is_image Whether the file is an image or not. 1 = image. 0 = not. image_width Image width image_height Image height image_type Image type (usually the file name extension without the period) image_size_str A string containing the width and height (useful to put into an image tag)
這可以幫助你。
$saved_file_name = $this->upload->data('file_name');
// will give you the filename along with the extension
如果你想在上傳之前只得到文件的擴展名,使用PHP核心:
$file_ext = pathinfo($_FILES["file"]["name"], PATHINFO_EXTENSION);
或
你上傳的文件後,你可以得到它的屬性讓它乾淨
$filename= $_FILES["file"]["name"];
$file_ext = pathinfo($filename,PATHINFO_EXTENSION);
- 1. 檢查文件擴展名在android中
- 2. 在Formview中檢查文件擴展名
- 3. TSaveDialog文件擴展名和[ofOverwritePromt]問題
- 4. C,C++文件擴展名問題
- 5. .htaccess和ForceType問題 - 擴展名文件?
- 6. 在Windows 7文件擴展名中搜索包含'#'的文件
- 7. Python:檢查文件名以擴展名列表中的擴展名結尾
- 8. 如何在IsolatedStorage中檢查文件的文件擴展名?
- 9. 搜索帶擴展名的文件
- 10. 文件擴展名的多重檢查
- 11. 檢查有效的文件擴展名
- 12. 檢查的文件擴展名
- 13. Windows蝙蝠:沒有擴展名的文件(點名稱問題)
- 14. 如何檢索特定文件擴展名的文件的文件路徑?
- 15. 檢索具有相同擴展名的文件數
- 16. PHP文件創建文件擴展名問題
- 17. Mercurial通過文件擴展名搜索
- 18. 搜索URL沒有文件擴展名
- 19. 自動檢測文件擴展名
- 20. php檢查文件擴展名爲
- 21. 檢測重複文件擴展名
- 22. Android - 檢查文件擴展名是.mp4
- 23. 用PHP檢查文件擴展名
- 24. ssh.net檢查文件擴展名
- 25. 文件擴展名檢測機制
- 26. PHP檢查文件擴展名
- 27. python argparse文件擴展名檢查
- 28. 文件擴展名
- 29. 文件擴展名[]
- 30. 文件擴展名