SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Addict jamesbond's Avatar
    Join Date
    Feb 2001
    Location
    The Netherlands
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is it possible to have an upload form in a form?

    I inserted uploadforms in my admin editpage.

    A user can upload a pic for each day of a trip. (it's also posssible to edit the content in the same section)

    There are multiple days on the page.

    After I insterted the uploadforms I noticed that my main form doesn't work anymore.
    Isn't it at all possible to have uploadforms embedded in a form?

    I can solve it by moving the uploadforms below my main editform, but I would like to have the uploadform for day 1 next to the content of day 1 and so on.

    Is there a solution ?

  2. #2
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sure. As a starting point read this section in the manual.

    http://www.php.net/manual/en/features.file-upload.php

    Note: there are additional issues if your server is running php as an apache module and safe_mode is on. But I'm sure someone will be able to help when/if that becomes a problem.

  3. #3
    SitePoint Addict jamesbond's Avatar
    Join Date
    Feb 2001
    Location
    The Netherlands
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm sorry maybe I wasn't clear enough.

    I don't have problems uploading pics and I already read that section, what I would like is to have it like this for each day on the generated form:
    (I didn't post my long code, but I created a short example instead)

    // MAIN FORM

    echo" <FORM method='post' action='$PHP_SELF'>";

    // while days<$num_rows

    echo"
    <tr BGCOLOR='F0F0F0'><td>Day$day/td><td><input type='text' name='content' value="<?php echo $content ?>" SIZE=50 MAXLENGTH=255></td></tr>

    ?>
    // UPLOAD FORM

    <FORM ENCTYPE="multipart/form-data" ACTION="_URL_" METHOD=POST>
    <input type="hidden" name='dayvar' value="<?php echo $day ?>">
    <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="1000">
    Send this file: <INPUT NAME="userfile" TYPE="file">
    <INPUT TYPE="submit" VALUE="Send File">
    </FORM>

    // END UPLOADFORM

    // end while days<num_rows

    <input type=hidden name='id' value="<?php echo $id ?>">
    <input type='Submit' name='submit' value='Submit'>
    </FORM>


    So when there are 4 days, there will be 4 sections with a content and uploadfield.

    Is something like this possible?

    As I said, my main form doesn't work anymore when I insert an uploadform in between the main <form> </form> tags

    You understand what I mean?
    Last edited by jamesbond; Mar 1, 2001 at 14:49.

  4. #4
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oic.

    You don't need two forms. You can "wrap" all your form elements with just the one form:

    <FORM ENCTYPE="multipart/form-data" ACTION="_URL_" METHOD=POST>
    // all the form elements can go here
    </FORM>

    Also, because you are generating these elements in a while loop you may want to create arrays to hold the form values

    <input type="hidden" name='dayvar[]' value="<?php echo $day ?>">
    <INPUT NAME="userfile[]" TYPE="file">

    I hope that's right. It's 7am here (Sydney) and it seams I have forgot to sleep


Bookmarks

Posting Permissions

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