Php photo gallery TWG | JFUploader | TWG Flash upload | WFU | Forum
https://www.tinywebgallery.com/forum/

SQL query after file deletion
https://www.tinywebgallery.com/forum/viewtopic.php?f=13&t=3032
Page 1 of 1

Author:  tcarr170 [ 16. Jun 2011, 01:18 ]
Post subject:  SQL query after file deletion

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

Author:  TinyWebGallery [ 16. Jun 2011, 07:46 ]
Post subject:  Re: SQL query after file deletion

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

Author:  tcarr170 [ 16. Jun 2011, 15:59 ]
Post subject:  Re: SQL query after file deletion

Perfect! Thanks Michael! :D

Author:  tcarr170 [ 16. Jun 2011, 16:27 ]
Post subject:  Re: SQL query after file deletion

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

Author:  TinyWebGallery [ 16. Jun 2011, 17:27 ]
Post subject:  Re: SQL query after file deletion

what is the output of your debug? in $filename it the filename.

- Michael

Author:  tcarr170 [ 16. Jun 2011, 17:41 ]
Post subject:  Re: SQL query after file deletion

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;

:?

Author:  TinyWebGallery [ 16. Jun 2011, 17:50 ]
Post subject:  Re: SQL query after file deletion

you should not use parameters that do not exists:

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

is written in the documention ;).

- Michael

Author:  tcarr170 [ 16. Jun 2011, 17:53 ]
Post subject:  Re: SQL query after file deletion

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?

Author:  tcarr170 [ 16. Jun 2011, 17:54 ]
Post subject:  Re: SQL query after file deletion

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!

Author:  TinyWebGallery [ 16. Jun 2011, 18:00 ]
Post subject:  Re: SQL query after file deletion

But the methods have defined parameters you cannot extend by simply adding one.

- Michael

Author:  tcarr170 [ 16. Jun 2011, 18:26 ]
Post subject:  Re: SQL query after file deletion

Understood, got it working with $fullpath. Thanks! :)

Page 1 of 1 All times are UTC + 1 hour [ DST ]
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/