D
D
dicem2017-03-26 16:23:09
PHP
dicem, 2017-03-26 16:23:09

How to send an image to the server using wordpress and phpmailer?

Hello. I am trying to upload an image to the server using the following method:

$uploaddir = 'uploads/'; // Relative path under webroot
 $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

 if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
   echo "File is valid, and was successfully uploaded.\n";
 } else {
   echo "File uploading failed.\n";
 }

however nothing comes out and the server gives me File uploading failed. Message could be sent.
I can confuse with directories very much. Please tell me how to be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Sklyarov, 2017-03-26
@0example

Check folder permissions (should be 777)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question