corfuitl Posted December 25, 2014 Share Posted December 25, 2014 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: Send to the linux server two files (I have done it). 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. 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, Quote Link to comment https://forums.phpfreaks.com/topic/293339-php-form-with-drop-down-list/ Share on other sites More sharing options...
hansford Posted December 25, 2014 Share Posted December 25, 2014 If you're using an html form to upload files then why do you need to execute a shell command. You can upload the files and use the $_FILES array to upload the file from the temp dir to a perm dir. If you need to run a shell command then you can use shell_exec() for that. Quote Link to comment https://forums.phpfreaks.com/topic/293339-php-form-with-drop-down-list/#findComment-1500638 Share on other sites More sharing options...
corfuitl Posted December 26, 2014 Author Share Posted December 26, 2014 Thank you for your reply. Do you know how can I show the 1st level of a directory? Quote Link to comment https://forums.phpfreaks.com/topic/293339-php-form-with-drop-down-list/#findComment-1500674 Share on other sites More sharing options...
ginerjm Posted December 26, 2014 Share Posted December 26, 2014 What is the 'first level of a directory'? I don't understand your question. Quote Link to comment https://forums.phpfreaks.com/topic/293339-php-form-with-drop-down-list/#findComment-1500684 Share on other sites More sharing options...
QuickOldCar Posted December 26, 2014 Share Posted December 26, 2014 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 Quote Link to comment https://forums.phpfreaks.com/topic/293339-php-form-with-drop-down-list/#findComment-1500722 Share on other sites More sharing options...
corfuitl Posted December 26, 2014 Author Share Posted December 26, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/293339-php-form-with-drop-down-list/#findComment-1500748 Share on other sites More sharing options...
corfuitl Posted December 26, 2014 Author Share Posted December 26, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/293339-php-form-with-drop-down-list/#findComment-1500750 Share on other sites More sharing options...
hansford Posted December 27, 2014 Share Posted December 27, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/293339-php-form-with-drop-down-list/#findComment-1500764 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.