treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Bringing an old file-upload form into the modern age

  • In the old days a common way to draw multiple file upload forms was to do something like:

      for ($i = 1; $i <= 3; $i++)
      {
        echo "
          <tr>
            <td><b>Image From Hard Drive</b></td>
            <td><input type=file id='userfile$i' name=userfile[] size=60></td>
            </tr>
          <tr>
            <td><b>Title</b></td>
            <td><input type=text id='phototitle$i' name=phototitle[] size=30 maxlength=100></td>
            </tr>
          <tr>
            <td valign=top><b>Caption</b></td>
            <td><textarea id='caption$i' name=caption[]  cols=45 rows=3></textarea></td>
            </tr>
        ";
      }
    

    So this is functional but exceedingly drab, if not limited in features.

    Are there any snippets or examples that offer both local (hard disk) and remote (url) options for image uploads? Perhaps with some basic ajaxy functionality?

    TIA!