Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder: Plugins & Add-ons:
remove uploaded data from database and files from server

 

 


ht1080z
User

Dec 18, 2011, 11:23 AM

Post #1 of 4 (1052 views)
Shortcut
remove uploaded data from database and files from server Can't Post

Hello,

(Using cmsb 2.13 and membership 1.06)

Is any way to remove selected images from the database?

i listed my section like:


Code
  list($accomRecords, $accomMetaData) = getRecords(array( 
'tableName' => 'accoms',
'where' => "owner='".mysql_escape(@$CURRENT_USER['num'])."'",
'allowSearch' => false,
'loadUploads' => true,
// 'debugSql' => true,
));
$accomRecord = @$accomRecords[0];
// showme($accomRecord);


and displayed the items like:


Code
<?php foreach ($accomRecord['acc_photos'] as $upload): ?> 
<li>
<a href="<?php echo $upload['urlPath'] ?>" rel="prettyPhoto">
<img src="<?php echo $upload['thumbUrlPath'] ?>">
</a>
<ul class="action-list">
<li>
Actions
</li>
<li>
<a href="<?php echo $upload['urlPath'] ?>" rel="prettyPhoto">view</a>
</li>
<li>
<a href="#">delete</a>
</li>
</ul>
</li>
<?php endforeach ?>


how can i trigger and delete selected images from the 'uploads' table and remove the files from the server?

i found only very few posts in the forum about this very important part and nowhere the right answer.

Please advise,
Karls
ht1080z


Jason
Staff / Moderator


Dec 19, 2011, 8:03 AM

Post #2 of 4 (1033 views)
Shortcut
Re: [ht1080z] remove uploaded data from database and files from server [In reply to] Can't Post

Hi,

Here is one approach you can take.

First, you have the "delete" link re-load the current page with the record num of the upload record in the url string like this:


Code
<?php foreach ($accomRecord['acc_photos'] as $upload): ?>  
<li>
<a href="<?php echo $upload['urlPath'] ?>" rel="prettyPhoto">
<img src="<?php echo $upload['thumbUrlPath'] ?>">
</a>
<ul class="action-list">
<li>
Actions
</li>
<li>
<a href="<?php echo $upload['urlPath'] ?>" rel="prettyPhoto">view</a>
</li>
<li>
<a href="?removeUpload=<?php echo $upload['num'];?>">delete</a>
</li>
</ul>
</li>
<?php endforeach ?>


Then, near the top of your page (before any getRecords call), you can remove the upload like this:


Code
 if (@$_REQUEST['removeUpload']) { 
removeUploads("num = '".mysql_escape($_REQUEST['removeUpload'])."'");
}


Hope this helps
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/ 


ht1080z
User

Dec 19, 2011, 11:11 AM

Post #3 of 4 (1028 views)
Shortcut
Re: [Jason] remove uploaded data from database and files from server [In reply to] Can't Post

Hello Jason!

Thank you for your quick response and solution!

Another one with the same picture gallery.
Side by the pictures i put text input to get information (titles) for the images from the users.
How can i update the uploads table with these array information?
Can i create $query for each record to update the info1?

Please advise,
Karls
ht1080z


Jason
Staff / Moderator


Dec 20, 2011, 11:20 AM

Post #4 of 4 (999 views)
Shortcut
Re: [ht1080z] remove uploaded data from database and files from server [In reply to] Can't Post

Hi,

Yes, if you can create a MySQL UPDATE query for any given record, using that records num field as a unique identifier.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/