Title: Undefined variable $uploadPath
Last modified: July 18, 2018

---

# Undefined variable $uploadPath

 *  Resolved [Peter Lawrenson](https://wordpress.org/support/users/lorro/)
 * (@lorro)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/undefined-variable-uploadpath/)
 * Using v3.3.4 which has just been published.
    In filesystem.php line 17, $scheme
   gives a string variable type on my site. So $uploadPath is not set at line 25
   leading to undefined variable notices for lines 32 and 33. Perhaps these few 
   lines could be visited before the next update.

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Nextendweb](https://wordpress.org/support/users/nextendweb/)
 * (@nextendweb)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/undefined-variable-uploadpath/#post-10503765)
 * Hi [@lorro](https://wordpress.org/support/users/lorro/),
    thank you for the feedback!
   Could you open that file again and send me the the `var_dump($wp_upload_dir);`?
   That would help a lot!
 *     ```
           public function __construct() {
               $this->_basepath    = realpath(WP_CONTENT_DIR);
               $this->_librarypath = str_replace($this->_basepath, '', N2LIBRARY);
   
               $this->paths[] = $this->_basepath;
   
               $wp_upload_dir = wp_upload_dir();
               var_dump($wp_upload_dir);
   
               $scheme        = parse_url($wp_upload_dir['basedir'], PHP_URL_SCHEME);
       ```
   
 *  Plugin Author [Nextendweb](https://wordpress.org/support/users/nextendweb/)
 * (@nextendweb)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/undefined-variable-uploadpath/#post-10503785)
 * Hi [@lorro](https://wordpress.org/support/users/lorro/),
    I think I found the
   issue. Could you try to open `filesystem.php` and replace the `__construct` method
   with the following:
 *     ```
           public function __construct() {
               $this->_basepath    = realpath(WP_CONTENT_DIR);
               $this->_librarypath = str_replace($this->_basepath, '', N2LIBRARY);
   
               $this->paths[] = $this->_basepath;
   
               $wp_upload_dir = wp_upload_dir();
               $scheme        = parse_url($wp_upload_dir['basedir'], PHP_URL_SCHEME);
   
               /**
                * Amazon S3 storage has s3://my-bucket/uploads upload path. If we found a scheme in the path we will
                * skip the realpath check so it won't fail in the future.
                * @url https://github.com/humanmade/S3-Uploads
                */
               if (!in_array($scheme, array('s3'))) {
                   $uploadPath = rtrim(realpath($wp_upload_dir['basedir']), "/\\");
                   if (empty($uploadPath)) {
                       echo 'Error: Your upload path is not valid or does not exist: ' . $wp_upload_dir['basedir'];
                       $uploadPath = rtrim($wp_upload_dir['basedir'], "/\\");
                   }
               } else {
                   $uploadPath = $wp_upload_dir['basedir'];
               }
   
               if (strpos($this->_basepath, $uploadPath) !== 0) {
                   $this->paths[] = $uploadPath;
               }
   
               self::measurePermission(N2Platform::getPublicDir());
           }
       ```
   
 * Does it solve the issue?
 *  Thread Starter [Peter Lawrenson](https://wordpress.org/support/users/lorro/)
 * (@lorro)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/undefined-variable-uploadpath/#post-10503792)
 * Sure. I use something like var_dump which does not show front end. I have redacted
   my domain name.
 *     ```
       [18-Jul-2018 06:20:02 UTC] Array
       (
           [path] => C:\Inetpub\vhosts\domain.com\httpdocs/wp-content/uploads/2018/07
           [url] => https://www.domain.com/wp-content/uploads/2018/07
           [subdir] => /2018/07
           [basedir] => C:\Inetpub\vhosts\domain.com\httpdocs/wp-content/uploads
           [baseurl] => https://www.domain.com/wp-content/uploads
           [error] => 
       )
       ```
   
 * $scheme gives the string: C
 *  Thread Starter [Peter Lawrenson](https://wordpress.org/support/users/lorro/)
 * (@lorro)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/undefined-variable-uploadpath/#post-10503810)
 * Yes, the revised__construct function does not give the undefined variable message.
   Thank you.
 *  Plugin Author [Nextendweb](https://wordpress.org/support/users/nextendweb/)
 * (@nextendweb)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/undefined-variable-uploadpath/#post-10503813)
 * I thank you for the report, [@lorro](https://wordpress.org/support/users/lorro/).
   We will release this bugfix today with a new version.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Undefined variable $uploadPath’ is closed to new replies.

 * ![](https://ps.w.org/smart-slider-3/assets/icon.svg?rev=2307688)
 * [Smart Slider 3](https://wordpress.org/plugins/smart-slider-3/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/smart-slider-3/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/smart-slider-3/)
 * [Active Topics](https://wordpress.org/support/plugin/smart-slider-3/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/smart-slider-3/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/smart-slider-3/reviews/)

## Tags

 * [uploadpath](https://wordpress.org/support/topic-tag/uploadpath/)

 * 5 replies
 * 2 participants
 * Last reply from: [Nextendweb](https://wordpress.org/support/users/nextendweb/)
 * Last activity: [7 years, 8 months ago](https://wordpress.org/support/topic/undefined-variable-uploadpath/#post-10503813)
 * Status: resolved