Support » Plugin: React Webcam » FTP upload location

  • Hello love the plugin, been using it for a couple of years for a tourism webcam.

    Recently had to change to a newer webcam and the new camera uploads to a folder with sub folders and creates a new date folder everyday.

    So the problem is I can’t tell React a specific folder location.

    Is there a way for react to search all folders in my ftp location for newest image? My date stamp is correct I just can’t get webcam to send image to room directory. I can tell react a specific folder which works but then the next day the webcam creates a new folder with date and sub folder.

    Thank you for any advice!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter mauibrew


    Can pay $50 paypal if you can help me with a solution. Thank you!

    Plugin Author Radek Matej


    Thanks for the kind words about the plugin. I don’t want any money, this is open source and I’m not able to provide any extensive support.

    The problem is not in React but in the PHP code that is searching for image files. Currently, it cannot search subdirectories:

    foreach (array_filter(glob($webcam_dir . '*'), 'is_file') as $path) {
      $last_filename = basename($path);
    return $last_filename;

    But you can modify the above code right in the installed plugin so that it searches recursively.

    I can’t help you more with that, sorry. If you are not capable of changing it on your own, get help from some PHP developer.

    mauibrew : I gave the same situation.
    Folders are like
    In this folder I have the local IP of the DVR device =
    In that one, for each day
    In these date named folder, the iage are uploaded with names like

    My typical image file path is :

    As said, the /2018-11-17/ part changes every day.

    I changed the get_last_filename function like this :

    function get_last_filename($subdir) {
    	$upload_dir = wp_upload_dir();
    	$webcam_dir = $upload_dir['basedir'] . '/' . WEBCAM_DIR . '/' ;
    	if ($subdir && preg_match('/[a-z0-9]/i', $subdir)) {
    		$webcam_dir .= $subdir . '/';
    	$files = getDirContents($webcam_dir);
    // Return the (relative path to the) file name - without the first '/' 
    	return deleteFirstChar(str_replace(realpath($webcam_dir), '',end($files)));

    My function getDirContents is like this

    function getDirContents($dir, &$results = array()){
        $files = scandir( $dir );
        foreach($files as $key => $value){
            $path = realpath($dir.DIRECTORY_SEPARATOR.$value);
            if(!is_dir($path)) {
    			if (filesize($path) > 0)
    				$results[] = $path;
            } else if($value != "." && $value != "..") {
                getDirContents($path, $results);
        return $results;

    as you already might have noticed, these directories will be filled up.
    I advise you to use a cron-like tool to clean them up.
    A simple shell script exampe :

    find /path/to/where/are/your/files/wp-content/uploads/webcam/ -depth -mindepth 1 -mmin +60 -uid 1001 -exec rm -rdf {} \;

    which runs every day and removes all files and folders older then 60 minutes.

    Plugin Author Radek Matej


    Thanks for sharing your solution.

    Hello I couldn’t get into my old acct –

    Can you post full updated plugin code (with your code added) so I can just cut and paste?

    I’m not great with where to add the new code.

    My webcam path is like this –

    Thank you!

    I tried adding this code (to replace the current function get last filename code) and the page just stops loading below the header.

    I’m totally puzzled as to how to make this code work, if anyone can help that would be great. Thank you!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘FTP upload location’ is closed to new replies.