• Hi all. First post here, and newb to php and the backend of wordpress

    I am creating an html form that users can complete a few text fields and upload an image.

    I have a php script that sends the text fields and the file location to a MySQL database. This script also tries to upload the picture to my uploads directory, but it doesn’t work. I am using exec-PHP to run the script on a static page.

    I am using wp_upload_dir() and move_uploaded_file() to upload the file to my upload directory.

    //This is the directory where images will be saved
     $upload_dir = wp_upload_dir();
     echo $uploads['path'] . '<br />';
    echo $uploads['url'] . '<br />';
    echo $uploads['subdir'] . '<br />';
    echo $uploads['basedir'] . '<br />';
    echo $uploads['baseurl'] . '<br />';
    echo $uploads['error'] . '<br />';
     $target = $upload_dir . basename( $_FILES['image']['name']); 
    
    //Writes the photo to the server
     if(move_uploaded_file($_FILES['image']['tmp_name'], $target))
     { 
    
     //Tells you if its all ok
     echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
    echo $uploads['path'] . '<br />';
    echo $uploads['url'] . '<br />';
    echo $uploads['subdir'] . '<br />';
    echo $uploads['basedir'] . '<br />';
    echo $uploads['baseurl'] . '<br />';
    echo $uploads['error'] . '<br />';
     }
     else { 
    
     //Gives and error if its not
     echo "Sorry, there was a problem uploading your file.";

    When I submit the form, the MySQL database is populated(query not shown), and I get the true response when I ask if the file was uploaded, BUT there is no information in $uploads

    I am thinking the image might need to be resized or something.

    Any help is appreciated. Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Public Image Upload’ is closed to new replies.