Jump to content

Free File from Memory after upload


Fábio Matte

Recommended Posts

 

I am using the UnimFileUpload component to upload images to the server, and it is going perfectly.

When this image arrives at the server, I need to rename it, but it doesn't work, because UniGUI holds this image in memory until I close the system or open another image.

I tried to use UnimFileUpload.free, and it frees up to change the image, however the Access Violation UniGUI when I try to send another one.

How can I upload this image to the server already renamed using UnimFileUpload or how can I release the memory file so that I can edit it?

Link to comment
Share on other sites

6 minutes ago, Fábio Matte said:

I am using the UnimFileUpload component to upload images to the server, and it is going perfectly.

When this image arrives at the server, I need to rename it, but it doesn't work, because UniGUI holds this image in memory until I close the system or open another image.

Hello,

Which build of UniGUI are you using?

How can we reproduce your issue?

Link to comment
Share on other sites

13 minutes ago, Sherzod said:

Hello,

Which build of UniGUI are you using?

How can we reproduce your issue?

Hello, I'm using FMSoft UniGUI v1.90.0.1543.

 

1. I put a UnimFileUpload component;
2. In a Button, I put the code below:

   With UnimFileUpload do
   begin
     Accept: = 'image';
     Capture: = '';
     Run;
   end;

3. In the OnCompleted of UnimFileUpload, the following:

procedure TmFrameLocais.UnimFileUploadCompleted(Sender: TObject; AStream: TFileStream);
var
  Nome      : String; // Extrai o da Nome da foto
  origem    : String;
  extensao  : String; // extensao
  destino   : String; // Caminho padrao
begin

  Nome      := ExtractFileName(UnimFileUpload.FileName); // Extrai o da Nome da foto
  origem    := UniServerModule.StartPath+'ArquivosCliente\FotosBens\';
  extensao  := ExtractFileExt(UnimFileUpload.FileName); // extensao
  destino   := origem + IntToStr(dmMobile.qryInventarioco_cliente.AsInteger)+ '\'; // Caminho padrao

  RenomarFotoBem(origem,destino, Nome, extensao);
end;

4. The Function to Rename the File [RenomarFotoBem]:

procedure TmFrameLocais.RenomarFotoBem(Origem, Destino, Nome, Extensao : String);
begin
  DeleteFile( destino + IntToStr(dmMobile.qryInventariochapa_atual.AsInteger) + Extensao ) ;
  CopyFile(PChar(origem + Nome), PChar(destino + Nome), False);
  RenameFile(destino+Nome, destino + IntToStr(dmMobile.qryInventariochapa_atual.AsInteger) + Extensao );

  DeleteFile( origem + Nome ) ;
end;

So, this DeleteFile does not trigger because UnimFileUpload continues to use the image that is in the

DeleteFile( origem + Nome ) ;

and then does not let me delete or rename.

That is, the file that is where the upload was made, I can't even rename or delete it. I can only do this in the destination folder.

Link to comment
Share on other sites

On 1/30/2021 at 1:43 AM, Fábio Matte said:

Hello, I'm using FMSoft UniGUI v1.90.0.1543.

 

1. I put a UnimFileUpload component;
2. In a Button, I put the code below:


   With UnimFileUpload do
   begin
     Accept: = 'image';
     Capture: = '';
     Run;
   end;

3. In the OnCompleted of UnimFileUpload, the following:


procedure TmFrameLocais.UnimFileUploadCompleted(Sender: TObject; AStream: TFileStream);
var
  Nome      : String; // Extrai o da Nome da foto
  origem    : String;
  extensao  : String; // extensao
  destino   : String; // Caminho padrao
begin

  Nome      := ExtractFileName(UnimFileUpload.FileName); // Extrai o da Nome da foto
  origem    := UniServerModule.StartPath+'ArquivosCliente\FotosBens\';
  extensao  := ExtractFileExt(UnimFileUpload.FileName); // extensao
  destino   := origem + IntToStr(dmMobile.qryInventarioco_cliente.AsInteger)+ '\'; // Caminho padrao

  RenomarFotoBem(origem,destino, Nome, extensao);
end;

4. The Function to Rename the File [RenomarFotoBem]:


procedure TmFrameLocais.RenomarFotoBem(Origem, Destino, Nome, Extensao : String);
begin
  DeleteFile( destino + IntToStr(dmMobile.qryInventariochapa_atual.AsInteger) + Extensao ) ;
  CopyFile(PChar(origem + Nome), PChar(destino + Nome), False);
  RenameFile(destino+Nome, destino + IntToStr(dmMobile.qryInventariochapa_atual.AsInteger) + Extensao );

  DeleteFile( origem + Nome ) ;
end;

So, this DeleteFile does not trigger because UnimFileUpload continues to use the image that is in the


DeleteFile( origem + Nome ) ;

and then does not let me delete or rename.

That is, the file that is where the upload was made, I can't even rename or delete it. I can only do this in the destination folder.

1.copy file

2.when restart the cache file will dispear automatic

Link to comment
Share on other sites

×
×
  • Create New...