CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Delete file

Print topic Send  topic

Author Message
Jerker

Posts: 4
Posted: 05/14/2010, 12:29 AM

I make a thumbnail of the file in a file upload component in one of my projects. Everything works great but with one little problem. I want to delete the thumbnail when the main file is deleted.

I have tried to do this in the afterdeletefile event with following code without success.

$filename = "../bilder/tn/" .$prylar->FileUpload1->GetValue();

unlink($filname);

Why is it not working?
View profile  Send private message
Gena

Posts: 591
Posted: 05/14/2010, 12:40 AM

Check this - unlink($filname);

should it be
unlink($filename);
?

Also check if your file exists and then delete like this

  
if(file_exists($filename)) 		  {   
  @unlink($filename);             
} else {  
  echo $filename . " doesn't exist";  
}

_________________
Gena
View profile  Send private message
Jerker

Posts: 4
Posted: 05/14/2010, 2:25 AM

oops, that was a typo in this example, but not in the real code.....

I tried your example, with the same result. Absolutely nothing happens.... No output from the echo statement and the thumbnail is still there.....

I add the following to se that the event fires of and the filename is correct:

$fh = fopen("../bilder/tn/" .'logg.html', 'a');
fwrite($fh, $filename);
fclose($fh);

The event fires as expected but the filename is missing. In my log file is only the path, no filename. So i know that everything except the $prylar->FileUpload1->GetValue() works as expected. .

I did the same in before delete with the same result.

Is there anny good solution to fetch the filename in the delete process?
View profile  Send private message
magus

Posts: 98
Posted: 05/15/2010, 10:15 AM

Hi,

It is possible that the Upload component deletes the deleted filename references when it deletes the file.

I suggest you run

print_r( $prylar->FileUpload1);
exit();

in the after delete event to see what values the fileupload component is storing at that time.

There are 4 places where the upload component stores filename info

->Value
->Text
->State[0]
->State[1]

If the filename data has been erased, then I suggest that you create an earlier event, store the file name in a global, then call that global variable in the afterdelete file event.


Regards,
Don A
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.