Good day.
I work with wordpress, namely writing a plugin. My task is to upload images from the computer to the server, then I need to give me the url and save it to a separate table in the database.
Basically, I use the wp_handle_upload function like this:
if (count($_FILES) > 5) { echo 'Слишком много файлов!'; return 0; } for ($i = 0; $i < count($_FILES) - 1; $i++) { $file = $_FILES[$i]; //print_r($file); $overrides = array('test_form' => false); $move_file = wp_handle_upload($file, $overrides); if ($move_file) { echo 'It`s work'; echo $move_file; } else { echo 'Ничего не работает.'; print_r($move_file); } } Next, I get something like this message:
Array ( [photo] => Array ( [name] => Array ( [0] => 69618.jpg [1] => banff-canada-lake-national.jpg ) [type] => Array ( [0] => image/jpeg [1] => image/jpeg ) [tmp_name] => Array ( [0] => /tmp/phpTWjUPN [1] => /tmp/phpuh8fFD ) [error] => Array ( [0] => 0 [1] => 0 ) [size] => Array ( [0] => 232720 [1] => 286619 ) ) ) that should report a successful download. But, I am confused by the boot path, namely "/ tmp / phpTWjUPN". I want all the pictures to be uploaded to wp-content / uploads, and from there I’ve pulled them in the future.
So, what to use and how to implement this?