0

Using Upload component from HTML5 Builder Embarcadero

Upload is a submit enabled button on the form. But the documentation doesn't tell me where the actual file goes. When this function is called after the supposed successful upload all the names of the upload do come out. I can see the temp file name, file name, file size, etc in the memo box. But when I try this from HTML 5 Builder in Windows 10 or on the server the uploaded target file seems to be no where. I must be missing something.

 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);
  }
kc3ase
  • 85
  • 7

1 Answers1

0

What is not shown in the example is you need to collect the file from the server temp directory and then place it where you want:

     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";
      }

Just add to the previous code and the file is saved to the server at the script location.

kc3ase
  • 85
  • 7