Php photo gallery TWG | JFUploader | TWG Flash upload | WFU | Forum

Get help for TinyWebGallery, the best image gallery. The forum is also home for the Joomla JFUploader, TWG Flash Uploader and the Wordpress flash uploader.
It is currently 28. Mar 2024, 12:11

This forum is readonly now. Please use the new forum if you don't find the answer to your question here. The new forum is at https://www.tinywebgallery.com/blog/forum/


All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: 16. Jun 2011, 01:18 
Offline

Joined: 23. Dec 2010, 21:01
Posts: 16
Hi Michael,

I created a plugin that inserts information to my MySQL table after a user uploads a file. However, I would like that information to be deleted if the user decides to delete the uploaded file. Where is the best place to do this MySQL delete query? I'd like to include it in the tfu_delete_files function in the tfu_helper, because that seems the most logical place, but I think I would need to bring in the database connection info there also, and I didn't know if that was a safe place to do that? I know there is a javascript call back for deleting, but I need to run SQL not Javascript.

I thought you might have a helpful idea :)

Thank you very much,

Tracy

Joomla 1.6.3
JFU 2.14
Server: localhost / development site


Top
 Profile  
 
PostPosted: 16. Jun 2011, 07:46 
Offline
Site Admin
User avatar

Joined: 1. Aug 2005, 12:53
Posts: 11232
write a plugin as well. You have to use the _after_process_file function then
see:
http://www.tinywebgallery.com/en/tfu/web_plugin.php#

- Michael


Top
 Profile  
 
PostPosted: 16. Jun 2011, 15:59 
Offline

Joined: 23. Dec 2010, 21:01
Posts: 16
Perfect! Thanks Michael! :D


Top
 Profile  
 
PostPosted: 16. Jun 2011, 16:27 
Offline

Joined: 23. Dec 2010, 21:01
Posts: 16
Hi, ok I need help again! I wrote the plugin and a test query, but I can't seem to access the filename, and I thought that variable was available. Here is my test function below. What am I doing wrong so that I can get just the filename?

function tc_delete_plugin_after_process_file($action, $fullpath, $folder, $filename ) {

if ( $action == "delete" || $action == "xdelete" ) {

$test = $filename;
$query = "INSERT INTO ". $db_table4. " ( `testing` ) ";
$query .= " VALUES ( '".$test."' )";
mysql_query($query,$db_connection) or tfu_debug("Cound not insert data: " . $query);

}
}

Thanks!
Tracy


Top
 Profile  
 
PostPosted: 16. Jun 2011, 17:27 
Offline
Site Admin
User avatar

Joined: 1. Aug 2005, 12:53
Posts: 11232
what is the output of your debug? in $filename it the filename.

- Michael


Top
 Profile  
 
PostPosted: 16. Jun 2011, 17:41 
Offline

Joined: 23. Dec 2010, 21:01
Posts: 16
Hi, here is the debug output:

06.16.2011 15:39:30 - ERROR 2 in \com_jfuploader\tfu\tc_delete_plugin.php, line 21: Missing argument 4 for tc_delete_plugin_after_process_file()
06.16.2011 15:39:31 - ERROR 8 in \com_jfuploader\tfu\tc_delete_plugin.php, line 76: Undefined variable: filename

Line 21 is: function tc_delete_plugin_after_process_file($action, $fullpath, $folder, $filename ) {
Line 76 is: $test = $filename;

:?


Top
 Profile  
 
PostPosted: 16. Jun 2011, 17:50 
Offline
Site Admin
User avatar

Joined: 1. Aug 2005, 12:53
Posts: 11232
you should not use parameters that do not exists:

_after_process_file($action, $fullpath, $folder) {

is written in the documention ;).

- Michael


Top
 Profile  
 
PostPosted: 16. Jun 2011, 17:53 
Offline

Joined: 23. Dec 2010, 21:01
Posts: 16
Also, I'm able to get the full path and folder variables, and it deletes the file, so I know everything else is working.

And In my other plugin (that runs after a file is uploaded), it gets the filename variable. But not in this plugin. Any of that help?


Top
 Profile  
 
PostPosted: 16. Jun 2011, 17:54 
Offline

Joined: 23. Dec 2010, 21:01
Posts: 16
Ah, ok. I was confused because also in the documentation it says:

Just check the existing plugins as examples. This function is called by tfu_upload.php after the upload or by tfu_file.php. The available parameters are:

$folder - relative folder the file is uploaded too.
$fullpath - the full path to the file - use this to copy the file somewhere.
$filename - the name of the file.
$action - the performed action - e.g. delete. See tfu_file.php for available actions.

So, I will try to use the fullpath variable as the identifier in my MySQL query.

Thanks!


Top
 Profile  
 
PostPosted: 16. Jun 2011, 18:00 
Offline
Site Admin
User avatar

Joined: 1. Aug 2005, 12:53
Posts: 11232
But the methods have defined parameters you cannot extend by simply adding one.

- Michael


Top
 Profile  
 
PostPosted: 16. Jun 2011, 18:26 
Offline

Joined: 23. Dec 2010, 21:01
Posts: 16
Understood, got it working with $fullpath. Thanks! :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
powered by phpbb | Datenschutz/ Privacy policy