Jump to content

Unable to upload an image to a folder from a custom backoffice controller


Recommended Posts

Hello, I want to upload an image from the backoffice, into a folder named uploads in the root directory of the module. Here is my code:

  <form action="/modules/customizeproducts/upload.php" enctype="multipart/form-data" method="POST">
      <input type="hidden" name="MAX_FILE_SIZE" value="30000" />
      Send this file: <input name="userfile" type="file" />
      <input type="submit" value="Send File" />
 </form>

my upload.php file:

$uploaddir = 'uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile);
echo '<pre>';
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);

print "</pre>";

Help would be greatly appreciated!!!!

 

Link to comment
Share on other sites

Turns out that it was a size issue that prevented me from uploading some images. I increased the maximum size and removed the "move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile);" from above the echo function. It was causing the error message to display always.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...