Jump to content

Form Field for Image Upload Module


supermandru

Recommended Posts

Hi, I am trying to create a module that allows users to upload image file. These images will not be attached to any products. For each picture to be uploaded I'd like to collect and store the the following configuration info:

  1. Path to file (text)
  2. Display order (number)
  3. Active/Inactive flag (1 or 0)
  4. Description(text)

I am creating a back office configuration page for this module, and I have been able to render all the attributes (i.e. form fields) except the one for the image file itself. I imagine the field for uploading the file itself will be an input element of type "file" i.e. <input type="file"/>.

 

My questions are: how do I specify (in my module's php code) a location where the file ends up in my and how do I get the path to the file location so I can store it as an attribute in the database (also within my php code) ?

 

If anyone can point me to sample code that does this or respond with code snippets, I'd really appreciate it.

 

Thanks.

Andrew.

Link to comment
Share on other sites

  • 1 month later...

Hi,

 

If you use the move_uploaded_file function in your module to upload images you can specify the destination in the second parameter.

 

And I advise you to store only the name of the file and not the entire path. It's the easiest way if you want to change the destinatation folder later.

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...