WordPress.org

Ready to get started?Download WordPress

Forums

[HELP] Upload image to a DIR and also onto a Database! (1 post)

  1. _OMEGA_
    Member
    Posted 4 years ago #

    Hi all, I'd like to know if it's possible to create a form using PHP to upload an image in an own directory and store it into the database too.
    I'm looking around for some code to understand how to do it, and write it into my plugin.
    I found this:

    $uploaddir = '/var/www/uploads/';
    $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 "Possible file upload attack!\n";
    }
    
    echo 'Here is some more debugging info:';
    print_r($_FILES);

    But this doesn't work in WP (maybe it's my fault), anyone can help me please? :'(

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.