Solarpitch Posted November 12, 2007 Share Posted November 12, 2007 Hey Guys, In my application I have 6 image fields. If a user uploads an image they must upload an image 1 which is the main image. So I dont want them to be able to jump to the 2nd or 3rd fields and upload their file there. I am just not sure how to go about defaulting them to upload image 1 first? Link to comment https://forums.phpfreaks.com/topic/77050-setting-an-image-field-as-a-default/ Share on other sites More sharing options...
Wuhtzu Posted November 12, 2007 Share Posted November 12, 2007 Are the user presented with 6 < input type="file" name="imagex"> at the same time or how is the "flow" of your application? Link to comment https://forums.phpfreaks.com/topic/77050-setting-an-image-field-as-a-default/#findComment-390192 Share on other sites More sharing options...
Solarpitch Posted November 12, 2007 Author Share Posted November 12, 2007 Hi, Yup they are. When the form loads the image fields are already there, hard coded in. Link to comment https://forums.phpfreaks.com/topic/77050-setting-an-image-field-as-a-default/#findComment-390194 Share on other sites More sharing options...
thebadbad Posted November 12, 2007 Share Posted November 12, 2007 If you have 6 input fields like Wuhtzu suggest, you should be able to use javascript (if it's possible in your application?) to disable all fields but the first one, and then enable the next field each time the previous is not empty anymore, if you get me? Link to comment https://forums.phpfreaks.com/topic/77050-setting-an-image-field-as-a-default/#findComment-390197 Share on other sites More sharing options...
Solarpitch Posted November 12, 2007 Author Share Posted November 12, 2007 Yeah I get ya .. thats grand. I'll google for some example's and see how I get on! Link to comment https://forums.phpfreaks.com/topic/77050-setting-an-image-field-as-a-default/#findComment-390200 Share on other sites More sharing options...
Wuhtzu Posted November 12, 2007 Share Posted November 12, 2007 I can see 3 solutions: #1: Use javascript as #thebadbad suggested #2: Just treat the image with lowest number as 1st and so forth. If the user selects image2, image4 and image6 translate that into image1, image2, image3 and give a f**k about what the user thought he or she did. #3: Do some validation with PHP and if they did not comply with your standards throw an error. Link to comment https://forums.phpfreaks.com/topic/77050-setting-an-image-field-as-a-default/#findComment-390201 Share on other sites More sharing options...
Solarpitch Posted November 12, 2007 Author Share Posted November 12, 2007 Would it make sense to use this? if(isset($_POST['image1'])){$image1set = TRUE;} if((isset($_POST['image2'])) && (!isset($image1set))){$image1error = "You must upload a main image in the image 1 field!";$error=1;} if((isset($_POST['image3'])) && (!isset($image1set))){$image1error = "You must upload a main image in the image 1 field!";$error=1;} if((isset($_POST['image4'])) && (!isset($image1set))){$image1error = "You must upload a main image in the image 1 field!";$error=1;} if((isset($_POST['image5'])) && (!isset($image1set))){$image1error = "You must upload a main image in the image 1 field!";$error=1;} if((isset($_POST['image6'])) && (!isset($image1set))){$image1error = "You must upload a main image in the image 1 field!";$error=1;} Link to comment https://forums.phpfreaks.com/topic/77050-setting-an-image-field-as-a-default/#findComment-390214 Share on other sites More sharing options...
Wuhtzu Posted November 12, 2007 Share Posted November 12, 2007 I haven't come up with the prettiest method of verifying this with PHP but I'm working on it Personally I would like to do this with PHP instead of JavaScript since javascript can be disabled making the application non-functional. Link to comment https://forums.phpfreaks.com/topic/77050-setting-an-image-field-as-a-default/#findComment-390224 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.