CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 File Delete

Print topic Send  topic

Author Message
datadoit.com
Posted: 10/15/2004, 8:22 PM

CCS 2.3.2; PHP4

I use the File Upload component to upload files to disk. Files uploaded are
saved like: [datetime stamp].filename.extension.

If I build an editable grid to display file info with a CheckBox_Delete, how
do I actually delete those files from disk? What methods have others used
to accomplish this?

Thnx.

DonB
Posted: 10/16/2004, 7:43 AM

You can put an unlink($filetodelete) function into the After Delete event,
so that the file is deleted after the record is successfully deleted.
However, note that with apache, the files which were uploaded are probably
owned by the user "apache" and you might discover that unlink can't delete
them due to insufficient permissions (it won't be "apache" that's trying to
delete them, probably it's "nobody"). The solution may be to chown() or
chmod() the files when initially uploaded, or perhaps merely set the upload
folder's permissions so the desired righs are inheriteed. These are
possible solutions, as I have not delved too deeply into apache behavior.
There might be a way to configure the accounts/ownership/permissions so that
the eventual "unlink" executes successfully. Hopefully an apache expert
will chime in.

--
DonB

http://www.gotodon.com/ccbth


"datadoit.com" <mike@datadoit.com> wrote in message
news:ckq45i$9tc$1@news.codecharge.com...
> CCS 2.3.2; PHP4
>
> I use the File Upload component to upload files to disk. Files uploaded
are
> saved like: [datetime stamp].filename.extension.
>
> If I build an editable grid to display file info with a CheckBox_Delete,
how
> do I actually delete those files from disk? What methods have others used
> to accomplish this?
>
> Thnx.
>
>

klwillis


Posts: 428
Posted: 10/16/2004, 10:54 PM

I think unlink should work - the permissions should be in place -
but let us know. ;-)

Quote datadoit.com:
CCS 2.3.2; PHP4

I use the File Upload component to upload files to disk. Files uploaded are
saved like: [datetime stamp].filename.extension.

If I build an editable grid to display file info with a CheckBox_Delete, how
do I actually delete those files from disk? What methods have others used
to accomplish this?

Thnx.


;-)
_________________
Kevin Willis, VP/CIO
HealthCare Information Technology Specialist
http://www.nexushealthcare.com
"Fast - Convenient - Quality-Care"

Medical Software Consulting Services
Email : klwillis@nexushealthcare.com
Skype : klwillis2006
View profile  Send private message
datadoit.com
Posted: 10/17/2004, 4:17 PM

It looks like unlink() will work just fine.

BeforeBuildDelete:
global $filename;
$filename = "yada.jpg";

AfterExecuteDelete:
global $filename;
unlink($filename);

works great.


However, now I can't seem to figure out what the filename is.

BeforeBuildDelete:

$filename = $grid->field->GetValue(); nor
$filename = $grid->ds->f("field");

don't have a value that I can tell. I think it's perhaps because this is a
grid using Checkbox_delete?


"klwillis" <klwillis@forum.codecharge> wrote in message
news:541720903bf0b6@news.codecharge.com...
>I think unlink should work - the permissions should be in place -
> but let us know. ;-)
>
>
Quote datadoit.com:
> CCS 2.3.2; PHP4
>
> I use the File Upload component to upload files to disk. Files uploaded
> are
> saved like: [datetime stamp].filename.extension.
>
> If I build an editable grid to display file info with a CheckBox_Delete,
> how
> do I actually delete those files from disk? What methods have others used
> to accomplish this?
>
> Thnx.
>
>
>
> ;-)
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

viktor
Posted: 04/05/2005, 11:47 PM

Quote datadoit.com:
It looks like unlink() will work just fine.

BeforeBuildDelete:
global $filename;
$filename = "yada.jpg";

AfterExecuteDelete:
global $filename;
unlink($filename);

works great.


However, now I can't seem to figure out what the filename is.

BeforeBuildDelete:

$filename = $grid->field->GetValue(); nor
$filename = $grid->ds->f("field");

don't have a value that I can tell. I think it's perhaps because this is a
grid using Checkbox_delete?

I've applied the follwing to 'Before Delte File'


if(file_exists($Grid->UploadControl->GetValue()))
{
unlink($Grid->UploadControl->GetValue());
}

And it works.
viktor
Posted: 04/05/2005, 11:47 PM

I've applied the follwing to 'Before Delte File'


if(file_exists($Grid->UploadControl->GetValue()))
{
unlink($Grid->UploadControl->GetValue());
}

And it works.

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.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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