HTML5_Builder上传组件PHP上传

时间:2016-02-14 01:48:55

标签: html5builder

使用HTML5 Builder Embarcadero中的上传组件

上传是表单上的提交启用按钮。但文档并没有告诉我实际文件的位置。在假定成功上传后调用此函数时,所有上传的名称都会出现。我可以在备忘录框中看到临时文件名,文件名,文件大小等。但是,当我从Windows 10中的HTML 5 Builder或服务器上尝试此操作时,上传的目标文件似乎无处可去。我一定错过了什么。

 function UploadClick($sender, $params)
    {
      //upload the file
      $this->UploadStatus->Caption = 'BtnUploadClick ' . $this->Upload1->FileName;
      $this->Memo1->AddLine('FileTmpName: ' . $this->Upload1->FileTmpName);
      $this->Memo1->AddLine('FileName: ' . $this->Upload1->FileName);
      $this->Memo1->AddLine('FileSize: ' . $this->Upload1->FileSize);
      $this->Memo1->AddLine('FileType: ' . $this->Upload1->FileType);
      $this->Memo1->AddLine('FileSubType : ' . $this->Upload1->FileSubType);
      $this->Memo1->AddLine('GraphicWidth: ' . $this->Upload1->GraphicWidth);
      $this->Memo1->AddLine('GraphicHeihgt: ' . $this->Upload1->GraphicHeight);
      if($this->Upload1->isGIF ())
          $tmp = ' is gif';
      if($this->Upload1->isJPEG())
          $tmp = ' is jpeg';
      if($this->Upload1->isPNG())
           $tmp = ' is png';
      $this->Memo1->AddLine('File Ext: ' . $this->Upload1->FileExt . $tmp);
  }

1 个答案:

答案 0 :(得分:0)

示例中未显示的是您需要从服务器临时目录中收集文件,然后将其放在您想要的位置:

     if(move_uploaded_file($this->Upload1->FileTmpName, $this->Upload1->FileName))
      {
          echo "File is valid, and was successfully uploaded.\n";
      }
      else
      {
         echo "Possible file upload attack!\n";
      }

只需添加到上一个代码,文件就会保存到脚本位置的服务器上。