Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
File-uploaded hook in plugin
#1
I've just started getting into GetSimple, and have put together my first small plugin. All works fine. I'm now thinking about another, that would allow some extra details to be entered and attached to an uploaded file, especially an image file.

I see from searching other posts that the function called by the file-uploaded hook has access to the $_FILES variable, which contains various details about the file just uploaded. I can see from the upload.php source that the hook is invoked just after the file is moved to its resting-place in the directories under "uploads". I can also see how the full destination path is built from the $_GET['path'] parameter. Can a plugin ascertain this location in the file-uploaded hook function, without reconstructing what upload.php does? Couldn't the hook simply pass the full pathname to the hook function as a parameter?
Reply
#2
Hooks do not have arguments, if you are looking to make a media meta data plugin, your best bet is to use this hook to do your own file scan and catalog on the uploads directory to detect new or changed files.

Using globals in hook callbacks is not recommended, it can break at anytime.

A future version of GS might have hook args, it is somewhat already in 3.4 but not yet implemented.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#3
(2015-09-14, 23:42:08)shawn_a Wrote: Hooks do not have arguments, if you are looking to make a media meta data plugin, your best bet is to use this hook to do your own file scan and catalog on the uploads directory to detect new or changed files.

Using globals in hook callbacks is not recommended, it can break at anytime.

A future version of GS might have hook args, it is somewhat already in 3.4 but not yet implemented.

OK, thanks for the very prompt answer.  I'm not in any hurry, I'll watch and wait...  Shy
Reply




Users browsing this thread: 1 Guest(s)