How to get this to work

August 5, 2009 by Kay Kentfield

This answer was just too succinct for me. Like many others, I needed more detail!

It took me ages to work out where George's code should go, and then I kept getting errors - but eventually I figured it out after some research.  Here's how to get it to work:

How to create a dynamic folder from a dynamic ID:

  1. In your upload form, add a hidden text field which has your dynamic ID field from your recordset. E.g:
    <input name="ID" type="hidden" id="ID" value="<?php echo $row_customer['ID']; ?>" />
    ('customer' is my recordset, 'ID' is my field)

  2. In your code, edit the folder destination (where you want your files uploaded to)
    In your php page find the line that starts with '$ppu->path ='
    $ppu->path = "../uploads/".$_POST['ID'];
    ../uploads/ is where I keep my uploaded images, but you may have a different name.
    .$_POST is how to use the form field to become your folder name. 
    ID is the name of the hidden field

  3. If you get an 'invalid index' error, suppress it:
    This error occurs because I'm not using POST to send my ID until my form is submitted (so PHP can't find it until the form is submitted). Nothing to worry about, just suppress the error:
    Add this code: <?php error_reporting (E_ALL ^ E_NOTICE); ?>
    above the head section in your document.
    I placed mine just after the script links, e.g:
    <?php require_once('../../../ScriptLibrary/incPureUpload.php'); ?>
    <?php require_once('../../../ScriptLibrary/cGraphicMediator.php'); ?>
    <?php error_reporting (E_ALL ^ E_NOTICE); ?>

Hope that helps all the people who have been looking for a detailed answer with examples.

:-)

How to get this to work

August 5, 2009 by Kay Kentfield

You can't read my full previous review, so here's my full answer in the forum:

http://www.dmxzone.com/forum/topic/43692/