Jump to content

How to pick a file on the local filesystem


Recommended Posts

Hi,

already posted on forums, but since I have got zero replys, trying in support (I'm a regular customer so I expect some form of support).


Unit SmartCL.Controls.EditBox does not have a definition for the 'file' type in TW3InputType (SMS 2.1.2.3592)
Is there another way to obtain the same result, or is this by design?

I have tryed to patch the unit :

type
  TW3InputType = (itNone, itColor, itDate, itDateTime, itDateTimeLocal, itEmail,
    itMonth, itNumber, itRange, itSearch, itTel, itTime, itUrl, itWeek,
    itPassword, itFile);

function TW3EditBox.getType: TW3InputType;
var
  mText: String;
begin
  mText := LowerCase(w3_getAttribAsStr(Handle, 'type'));
  if mText = '' then Result := itNone else
  if mText = 'color' then Result := itColor else
  if mText = 'date' then Result := itDate else
  if mText = 'datetime' then Result := itDateTime else
  if mText = 'datetime-local' then Result := itDateTimeLocal else
  if mText = 'email' then Result := itEmail else
  if mText = 'month' then Result := itMonth else
  if mText = 'number' then Result := itNumber else
  if mText = 'range' then Result := itRange else
  if mText = 'search' then Result := itSearch else
  if mText = 'tel' then Result := itTel else
  if mText = 'time' then Result := itTime else
  if mText = 'url' then Result := itUrl else
  if mText = 'week' then Result := itWeek else
  if mText = 'password' then Result := itPassword else
  if mText = 'file' then Result := itFile;
end;

procedure TW3EditBox.setType(const aValue: TW3InputType);
var
  mToWrite: String;
begin
  if (Handle) then
  begin
    case aValue of
      itNone:           mToWrite := '';
      itColor:          mToWrite := 'color';
      itDate:           mToWrite := 'date';
      itDateTime:       mToWrite := 'datetime';
      itDateTimeLocal:  mToWrite := 'datetime-local';
      itEmail:          mToWrite := 'email';
      itMonth:          mToWrite := 'month';
      itNumber:         mToWrite := 'number';
      itRange:          mToWrite := 'range';
      itSearch:         mToWrite := 'search';
      itTel:            mToWrite := 'tel';
      itTime:           mToWrite := 'time';
      itUrl:            mToWrite := 'url';
      itWeek:           mToWrite := 'week';
      itPassword:       mToWrite := 'password';
      itFile:           mToWrite := 'file';
    end;
    w3_setAttrib(Handle, 'type', mToWrite);
  end else
    raise EW3Exception.CreateFmt(CNT_ERR_METHOD,
      [{$I %FUNCTION%}, ClassName, 'Invalid handle error']);
end;

if I open the project in Firefox there is a 'browse' button but the Text property of the EditBox contains only the filename without the path.

Any suggestion?

 

Link to post
Share on other sites
  • Administrators

Sorry.

 

I'll look into this.

 

The FileAPI itself (http://www.w3.org/TR/FileAPI/) should be included in the latest update. 

Take a look at W3C.File.pas under RTL\APis\W3C...

 

See also some info about this here:

http://www.html5rocks.com/en/tutorials/file/dndfiles/

https://developer.mozilla.org/en-US/docs/Using_files_from_web_applications

 

 

 

The input type seems to be missing in the RTL, but can be patched as you describe.

I know that there's limited support for this is input type on mobile browsers, but I'm not sure about the state on desktop browsers.  Will try to find out...

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...