Jump to content

How to Convert FilePath to URL?


newsanti

Recommended Posts

You can use the helper function NewCacheFileUrl:

targetFile:= ServerModule.NewCacheFileUrl(False, 'jpg'{file extension}, '', '', AUrl, True);

CopyFile(PChar(SrcFileName),PChar(targetFile),false);

Then use the AUrl for your end user.

  • Like 1
Link to comment
Share on other sites

5 hours ago, mhmda said:

You can use the helper function NewCacheFileUrl:

targetFile:= ServerModule.NewCacheFileUrl(False, 'jpg'{file extension}, '', '', AUrl, True);

CopyFile(PChar(SrcFileName),PChar(targetFile),false);

Then use the AUrl for your end user.

Why MainModule.Background.Url:= AURL;   Not Show Background Image. 

Link to comment
Share on other sites

1 hour ago, mhmda said:

Are you trying to change mainmodule background image @ runtime?

Yes.. but no effect...
.............................................
ChangeAppWallPaper procedure work OK. if run localhost only.
if Apply to Production Server ...don't work..
with Access Violation Error.
.............................................
procedure TisteeuniGUICustomFormLink.ChangeAppWallPaper(
  const AFileName: String; const ADefault: Boolean);
var
  oMainForm: TUniForm;
  oPanel: TUniPanel;
  S: String;
begin
  if Not System.IOUtils.TFile.Exists(AFileName) then Exit;
  S:= AFileName;
  if Not ADefault then
    begin
      S:= ExtractFileName(AFileName);
      S:= isteePlatform.Context.DesktopWallpaperPath+S;
    end;
  oMainForm:= UniApplication.UniMainModule.MainForm as TuniForm;
  oPanel:= TuniPanel(oMainForm.FindComponent('Panel_BACKGROUND'));
  if Assigned(oPanel) then
    begin
      oPanel.Background.Picture.LoadFromFile(S);   << Access Violation *** Picture object ***
      S:= oPanel.Background.ImageUrl;

      UniSession.AddJS(oPanel.JSName+'.setStyle("background-image", ''url("'+S+'")'');');
      UniSession.AddJS(oPanel.JSName+'.setStyle("background-size", ''cover'');');
    end;
end;
 

Link to comment
Share on other sites

It will NOT change !!!

You have to do it with the help of the client-side, this will help you, replace MainForm.form with your target object:

UniSession.AddJS('MainForm.form.bodyCls="desktopwallpaper1"');

and in servermodule add your css  for bg images:

.desktopwallpaper1
{
 background-image: .........
}
.desktopwallpaper2
{
 background-image: .........
}
.desktopwallpaper3
{
 background-image: .........
}

 

  • Like 1
Link to comment
Share on other sites

14 hours ago, mhmda said:

It will NOT change !!!

You have to do it with the help of the client-side, this will help you, replace MainForm.form with your target object:


UniSession.AddJS('MainForm.form.bodyCls="desktopwallpaper1"');

and in servermodule add your css  for bg images:


.desktopwallpaper1
{
 background-image: .........
}
.desktopwallpaper2
{
 background-image: .........
}
.desktopwallpaper3
{
 background-image: .........
}

 

Good Idea
 

Link to comment
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...