Delphi 搭配 CodeIgniter上傳檔案

php端

[php]
$str_no = $this->input->post(‘strid’);
$filename1 = $this->input->post(‘filename’);
$config[‘upload_path’] = ‘./uploads/’;
$new_name = $str_no.’-‘.$filename1;
$config[‘file_name’] = $new_name;
$config[‘allowed_types’] = ‘*’;
$config[‘max_size’] = ‘1000000000’;

$this->load->library(‘upload’,$config);

if ( ! $this->upload->do_upload(‘myfile’))
{
$error = array(‘error’ => $this->upload->display_errors());

}
else{
$data = array(‘upload_data’ => $this->upload->data());
print_r($data);
}
[php]

Delphi

use IdMultipartFormData
var
PostData: TIdMultipartFormDataStream;
begin
PostData := TIdMultipartFormDataStream.Create;
try
PostData.AddFile(‘myfile’, Self.GetApplicationPath + ‘\file.ini’);
PostData.AddFormField(‘strid’,’999′);
PostData.AddFormField(‘filename’,’file.ini’);

idhttp1.Post(‘http://xxxx/Home/upload/’, PostData)
finally
PostData.Free;
end;