According to the link to the function, it get_bloginfo('wpurl')will return the URL. If you want to access the local file system, you need a real file path, not a URL.
Try this for the first line:
$myPath = WP_CONTENT_DIR.'/uploads/'; // this is full path
WP_CONTENT_DIRdefined in the configuration file and should point to wp-contentyour installation folder .
source
share