Jump to content

Php form with drop down list


corfuitl

Recommended Posts

Hello all,

 

I am new in php and would like to help me in in code.

 

I would like to implement a html form that will upload to my linux server some files, some info as well and will run a bash command.

 

To be more clear, users will:

  1. Send to the linux server two files (I have done it).
  2. Select from a drop down list a specific directory, and once this specific directory has been selected to activate one other drop down menu with its childs.
  3. Send all those info to a bash script.

For case b, assume that we have the following structure

my_dir/cars/brand1

my_dir/cars/brand2

my_dir/cars/brand3

my_dir/motors/brand5

my_dir/motors/brand6

 

the first drop down list should list only cars and motors while the second only brand1, brand2, and brand3 if cars is selected or brand5 and brand6 if motors is selected.

 

For case c, once the form is submitted, I would like the command:

./script.sh –a uploadedfile1 –b uploadedfile2 –c dropdown1 –d dropdpwn2

 

Any help is appreciated.

 

Best,

Link to comment
Share on other sites

 

Thank you for your reply. Do you know how can I show the 1st level of a directory?

 

I don't see the reason for a shell command, can upload multiple files through a form.

 

When you write a script to upload files...it's you who determines where to save them or the location of it in a database.

 

You can create piles of folders acting as category/tags and carefully place each image into the proper folder.(Too messy and hard to search)

 

A better method is a database structure such as id,title,filename,timestamp/date,category

Keep all images in the same folder and just add another column in a database to categorize it.

If you want multiple categories you should create another table for categories and be marking which image id belongs to said category.

 

Make a form with the title and category, rename the image with a filename such as timestamp.ext or pretty_safe_name_timestamp.ext

Do not use their uploaded file names.

file upload

time()

 

As for displaying in your script you can do a database query for categories, make a search for titles, sort by date or id

For image display you append the default image folder and then the filename from the database

./images/$filename

Link to comment
Share on other sites

What is the 'first level of a directory'?  I don't understand your question.

 

Hi I mean that I want to have a drop down menu that will show the 1st level of a given directory and once one of a directory is selected to open a new drop down that will show its sub-directories.

Link to comment
Share on other sites

I don't see the reason for a shell command, can upload multiple files through a form.

 

When you write a script to upload files...it's you who determines where to save them or the location of it in a database.

 

You can create piles of folders acting as category/tags and carefully place each image into the proper folder.(Too messy and hard to search)

 

A better method is a database structure such as id,title,filename,timestamp/date,category

Keep all images in the same folder and just add another column in a database to categorize it.

If you want multiple categories you should create another table for categories and be marking which image id belongs to said category.

 

Make a form with the title and category, rename the image with a filename such as timestamp.ext or pretty_safe_name_timestamp.ext

Do not use their uploaded file names.

file upload

time()

 

As for displaying in your script you can do a database query for categories, make a search for titles, sort by date or id

For image display you append the default image folder and then the filename from the database

./images/$filename

Hi, Thank you for your time. I don't think that the database will help me. The bash script will start once the files and other info have been uploaded to the server.

Link to comment
Share on other sites

 

 

I want to have a drop down menu that will show the 1st level of a given directory and once one of a directory is selected to open a new drop down that will show its sub-directories.

 

You can use Ajax for this functionality. Once a directory is selected a JavaScript event is triggered that sends the selected value via Ajax to some PHP file on the server. PHP can then query the database for the information required to fill the child drop down and return that information to Ajax. The second drop down is then dynamically filled with the appropriate values.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.