Skip to content
Advertisement

file upload to a folder in wordpress

I have use the below written code for move the file to a folder named “training”.

JavaScript

To save the image i wrote this

JavaScript

But i could not get any result. Did i do any mistake. please help me.

This is my entire code

JavaScript

Advertisement

Answer

You are doing it wrong. $upload_dir['baseurl'] gives the URL to the uploads directory not the absolute path to the directory. You can’t upload or move files using URL.

HTTP wrapper does not support writeable connections

So $upload_dir['baseurl'] should change to $upload_dir[‘basedir’].

It should be

JavaScript

Also make sure that your form’s enctype is set to multipart/form-data (enctype="multipart/form-data")

UPDATE

WordPress profile form doesn’t have enctype attribute by default. By you can add that using a hook. Add this in your themes functions.php

JavaScript

Hope this helps

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement