[Overview][Constants][Procedures and functions] | Reference for unit 'pwumain' (#powtils_main) |
Source position: pwumain.pas line 187
function SaveUpFile( |
const name: String; |
const fname: String |
):Boolean; |
The name parameter is the name of the FORM 'browse for file' html widget that is passed in to the program. The fname parameter is a path of your choice to save the file on the server.
const FUPL = 'fupl'; procedure OutBr(s: string); begin Out(s); Out('<br>'); end; procedure ShowForm; begin Out('<FORM METHOD=POST ACTION="" enctype="multipart/form-data">' + '<input name='+FUPL+' type=file size=20> ' + '<br><br>'+ '<input type=submit>' + '</FORM>'); Out('<p>Click to upload file and get info</p> '); end; procedure ProcessUpfile; var FileOut: string; AbsoluteFname: string; begin // note: make sure public_html/test/ exists on server FileOut:= '/test/'+GetUpFileName(FUPL); // absolute path to save file AbsoluteFname:= SERV.DocRoot() + FileOut; OutBr('Upfile name: ' + GetUpFileName(FUPL)); OutBr('Upfile type: ' + GetUpFileType(FUPL)); OutBr('Upfile size: ' + IntToStr(GetUpFileSize(FUPL))); if SaveUpFile(FUPL, absoluteFname) then Out('saved to: <a href="'+fileout+'">'+ fileout +'</a>' + '<br>absolute path: ' + absoluteFname); else Out('error saving file. example: directory may not exist' + '<br>tried to save to: ' + absoluteFname); end; begin // checks if user submitted file from form if IsUpFile(FUPL) then ProcessUpFile else ShowForm; end.