WordPress download_url() with local files import
-
I want to set post featured image from local stored picture, but I can’t create temporary file on server.
When I try to do that:
require_once(ABSPATH . "wp-admin" . '/includes/image.php'); require_once(ABSPATH . "wp-admin" . '/includes/file.php'); require_once(ABSPATH . "wp-admin" . '/includes/media.php'); $url = ABSPATH . 'import/photos/test/test.jpg'; // DON"T WORK, BUT FILE EXISTS // $url = 'https://example.com/import/photos/test/test.jpg'; - WORKS $tmp = download_url( $url ); var_dump($tmp);
I have that error on tmp:
object(WP_Error)#11636 (2) { ["errors"]=> array(1) { ["http_request_failed"]=> array(1) { [0]=> string(46) "Предоставлен неверный URL." } } ["error_data"]=> array(0) { } }
Path to stored file is correct. When if I try to import that file from web URL it upload correctly and shows me correct name of temp file
string(20) "/tmp/test-jMHjga.tmp"
.Why I can’t use local server paths?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘WordPress download_url() with local files import’ is closed to new replies.