Jump to content

Setting an image field as a default?


Solarpitch

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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