Results 1 to 4 of 4

Thread: Validating dynamically created fields

  1. #1
    Join Date
    May 2003

    Validating dynamically created fields

    Hi, I have an image upload page that creates a dynamic number of file upload boxes depending on how many the user wants.

    They are numbered in sequential order Image0,Image1,Image2 etc...

    The user then selects files for each input box and clicks the Submit button.

    On the next page i need to check each one of these file input boxes and validate them to see if they are images and of the correct size etc...

    The validation is no problem, but i can't figure out how to get the values of the input boxes. I keep track of how many were created thru a hidden input field. so i know how many files i need to validate but i cant figure out how to get the values of the file input fileds.

    I tried a For loop to loop the number of times that there are fields and create a varible with the same names as the fields and try to validate them but ofcourse the variables are empty because they are new variables and not the ones i passed from the last form.

    Here is my code.

    PHP Code:
    //Image checking
    For($Counter =0$Counter $txtNumImages$Counter++){
    //Create variable with the same name as the input fields
    $Image "$Image".$Counter;
    $TypeTest "False";
    ereg_replace (" ""_"$Image_name);
          If ((!empty(
    $Image) AND $Image_type == "image/pjpeg" AND $Image_type == "image/jpeg") OR $Image_type == "image/gif")$TypeTest "True";
          If (!
    $TypeTest$Error .= "<img src=\"../images/errorarrow.gif\" border=0>Image must be in either .jpg or .gif format.<br>";
    // Check To Make Sure Image Is Of Right Dimensions //
    $ImageSize getimagesize("$Image");
    $ImageWidth $ImageSize[0];
    $ImageHeight $ImageSize[1];
         If (
    $ImageWidth 400 Or $ImageHeight 160)$Error .= "<img src=\"../images/errorarrow.gif\" border=0>Image is not the correct size, it must be exactly 400x160 in size.<br>";
    If (
    $Error != ""){
    $FullPath "/home/httpd/html/allsites/specialeventimages/";
    CopyError_Message("<img src=\"../images/errorarrow.gif\" border=0>Unable to copy image.");
    unlink ($Image);

    All the validation code works great.. i just can't figure out how to get the values of the dynamically created input fileds on the last page.

    Any help is appreciated!


  2. #2
    Join Date
    Feb 2003
    How are you passing the variables across - if you are using post, you set the variables with

  3. #3
    Join Date
    Nov 2002
    Dartmoor [Holiday]
    As these are file uploads, shouldn't you be using $_FILES or $HTTP_POST_FILES?

    See this page:

    "If youíre not using valid HTML, then you havenít created a Web page. You may have created something else, but it isnít a Web page." - Joe Clark

    Do something amazing (USA) | Make Poverty History

  4. #4
    Join Date
    Feb 2003
    Good point.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles