bizerk Posted May 9, 2007 Share Posted May 9, 2007 Alright so basically I have Three Submit buttons and a image uploader with user verifcation. What i want to happen is when you press the button that says "Submit Pictures", it will upload pictures to the "files/pictures/" directory, when you press "Submit School", it will upload files to the "files/school/" directory, and when you press "Submit Random", it will upload to the "files/random" directory. I made the script so that right now if the user and password are correct it wil upload to the directory "/files". Can anyone tell me what to do from the script i have so far: <? $lol = rand(1,100); $browser = $REMOTE_ADDR; $name = $_POST['name']; $password = $_POST['password']; $Submit = $_POST['Submit']; $Submitschool = $_POST['Sschool']; $Submitrandom = $_POST['Srandom']; function uploadFiles($key) { $lol = rand(1,100); copy ($_FILES[$key]['tmp_name'], "files/$lol".$_FILES[$key]['name']) or die ("Error Occured When Uploading Image File to Directory"); echo "<br><u><b>File: {$_FILES[$key]['name']} Status</u></b><br><br> File Size: {$_FILES[$key]['size']}<br> File Type: {$_FILES[$key]['type']}<br> <br><br> File {$_FILES[$key]['name']} was uploaded Succesfully.<br>"; echo"<br> Click <a href='files/pictures/'>here</a> to see your files<br>"; } if($_POST['Submit']) { if($name =="test123" && $password =="lawlzzz" || $name=="rofl" && $password=="lolzorz") { foreach ($_FILES as $key=>$file) { if (!empty($file['name'])) { uploadFiles($key); } } }else{ echo "Wrong Credentials, Please try to Login Again"; } } ?> So once again... how would i make it so if i had three buttons: <input type="submit" name="Spictures" value="Submit PICTURES" /> </p> <p align="center"><input type="Sschool" name="Submit" value="Submit SCHOOL STUFF" /> </p> <p align="center"> <input type="submit" name="Srandom" value="Submit Random" /> What would i need to do to make my script so it uploads the FILES to the specific directory when the button is pressed :/ Quote Link to comment Share on other sites More sharing options...
triphis Posted May 9, 2007 Share Posted May 9, 2007 You would need to incorporate javascript, and have the form actions depend on the button pushed. the school submit button could have a onClick="submitSchool()" attribute, and so on. The javascript functions could make the browser submit the info to formprocess.php?type=school type=random type=pictures etc And then you could pull that variable from the URL and have your process.php page know which branch to upload to, based on that variable Quote Link to comment Share on other sites More sharing options...
bizerk Posted May 9, 2007 Author Share Posted May 9, 2007 Okay So yeah, add that java-add on and than make the php functions whatT? give me an example of what one button uploader would look like with the java script... please... Quote Link to comment Share on other sites More sharing options...
triphis Posted May 9, 2007 Share Posted May 9, 2007 Actually, I rethought my answer, and I decided I don't like it haha. I wouldn't even go that far. This can have such a simple solution... Why have 3 submit buttons? Why not have ONE submit button, and just make use of 3 radio buttons, one for each action you want? <input type="radio" name="uploadwhere" value="pictures"> Pictures<br> <input type="radio" name="uploadwhere" value="school"> School<br> <input type="radio" name="uploadwhere" value="random"> Random<br> Then, one the process page, just use: $_GET['uploadwhere']; to find out which of the 3 was chosen, and build your if/switch statements around that I'm sorry, I'm not very good at giving exact answers with codes... I just explain how I would solve it. Hopefully you understand what I outlined above. If you want to wait a bit, I am sure another person will help you out here Quote Link to comment Share on other sites More sharing options...
bizerk Posted May 9, 2007 Author Share Posted May 9, 2007 ah yeah that is a lot easier. I am not as good at JAVA as i am at php. alright well i understand that, but last time i tried radio buttons it didn't work well :/. Anyone give me an example of how to use a IF with radiobutton instance? Quote Link to comment Share on other sites More sharing options...
bizerk Posted May 10, 2007 Author Share Posted May 10, 2007 Can anyone give me an example of how I would make a script that if a radio button lets say named 'pictures' is pressed and is submitted how would I make it so if that radio button was selected copy blablabla etc.? Quote Link to comment Share on other sites More sharing options...
Bphilow Posted October 6, 2009 Share Posted October 6, 2009 Alright so basically I have Three Submit buttons and a image uploader with user verifcation. What i want to happen is when you press the button that says "Submit Pictures", it will upload pictures to the "files/pictures/" directory, when you press "Submit School", it will upload files to the "files/school/" directory, and when you press "Submit Random", it will upload to the "files/random" directory. I made the script so that right now if the user and password are correct it wil upload to the directory "/files". Can anyone tell me what to do from the script i have so far: <? $lol = rand(1,100); $browser = $REMOTE_ADDR; $name = $_POST['name']; $password = $_POST['password']; $Submit = $_POST['Submit']; $Submitschool = $_POST['Sschool']; $Submitrandom = $_POST['Srandom']; function uploadFiles($key) { $lol = rand(1,100); copy ($_FILES[$key]['tmp_name'], "files/$lol".$_FILES[$key]['name']) or die ("Error Occured When Uploading Image File to Directory"); echo "<br><u><b>File: {$_FILES[$key]['name']} Status</u></b><br><br> File Size: {$_FILES[$key]['size']}<br> File Type: {$_FILES[$key]['type']}<br> <br><br> File {$_FILES[$key]['name']} was uploaded Succesfully.<br>"; echo"<br> Click <a href='files/pictures/'>here</a> to see your files<br>"; } if($_POST['Submit']) { if($name =="test123" && $password =="lawlzzz" || $name=="rofl" && $password=="lolzorz") { foreach ($_FILES as $key=>$file) { if (!empty($file['name'])) { uploadFiles($key); } } }else{ echo "Wrong Credentials, Please try to Login Again"; } } ?> So once again... how would i make it so if i had three buttons: <input type="submit" name="Spictures" value="Submit PICTURES" /> </p> <p align="center"><input type="Sschool" name="Submit" value="Submit SCHOOL STUFF" /> </p> <p align="center"> <input type="submit" name="Srandom" value="Submit Random" /> What would i need to do to make my script so it uploads the FILES to the specific directory when the button is pressed :/ I had the same problem I solved it with more then one forms Quote Link to comment 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.