Ⅰ delphi 如何獲取文件的大小和類型
示例代碼如下:
首先,uses 添加IdGlobalProtocols。
2.
functionTForm1.GetFileSizeStr(fName:string):string;
varnSize:Integer;
begin
nSize:=FileSizeByName(fName);
ifnSize>1073741824then
Result:=FormatFloat('###,##0.00G',nSize/1073741824)
elseifnSize>1048576then
Result:=FormatFloat('###,##0.00M',nSize/1048576)
elseifnSize>1024then
Result:=FormatFloat('###,##00K',nSize/1024)
else
Result:=FormatFloat('###,#0B',nSize);
ifLength(Result)>2then
ifResult[1]='0'then
Delete(Result,1,1);
end;
procereTForm1.Button1Click(Sender:TObject);
begin
ShowMessage('文件大小是:'+GetFileSizeStr('d: able.mdb'));
end;
示例截圖:
Ⅱ delphi編寫上傳文件大小限制如何取消
找到php.ini文件,
編輯該文件
搜索:memory_limit、post_max_size、upload_max_filesize、max_execution_time、max_input_time
一般默認的設置值為:
memory_limit=128M //相當於單個腳本可調用內存大小
post_max_size=8M //上傳文件大小上限
upload_max_filesize=2M//默認上傳文件大小,這個就是2M的限制!
max_execution_time=30//最大執行時間,頁面等待時間
max_input_time=60//最大輸入時間?具體意義不明確,就是上傳時間相關
然後將其改為自己需要的值,例如:
memory_limit=128M
post_max_size=12M
upload_max_filesize=10M//這樣就改為可以傳10M以下的文件了
max_execution_time=60
max_input_time=60
重啟服務使得設置才能生效!