I have made a simple photo gallery with the help of a good tutorial I found. I am working on expanding it a bit to allow my site members to use it to upload images for use in other parts of my site.
I have a script called cne_prepare_upload.php that has the form that the user uses to choose and upload their image. I'm using a variable to show a different form to upload the avatar image. All of this data is passed to cne_upload.php to be processed.
My problem is that I can't sort out how to tell cne_upload.php which data it needs to process. For example, when someone uploads to the gallery, the image path is /images/cne/gallery; but when they upload an avatar it should be /images/cne/avatar. This path is set in cne_upload.php to determine where to copy the uploaded file.
So how do I add additional variables to this? I want to use if ( $_POST['avatar'] ) to choose the processing code to use.
Code: Select all
$photo_category_list = "<form enctype='multipart/form-data' action='cne_av_upload.php' method='post' name='upload_form'>";
$photo_category_list = $photo_category_list . "<table border='1' cellpadding='10' width='100%'><tr><td>Choose the character you would like to upload an avatar for.<br><br><select name='category'>";
while( $row = mysql_fetch_array($result) )
{
$photo_category_list = $photo_category_list . "<option value='" . $row['category_id'] . "'>" . $row['category_name'] . "</option>";
$numchars++;
}
$photo_category_list = $photo_category_list . "</select><br><br><br><br></td></td><tr><td><br>Select the image you wish to upload.<br><br>";
if ( !$numchars ) {
$photo_category_list = "<strong>You must first register a character to submit photos to the gallery.</strong>";
}
mysql_free_result($result);
// Lets build the Photo Uploading fields
$photo_upload_fields = "";
while( $counter <= $number_of_fields )
{
$photo_upload_fields = $photo_upload_fields . "<tr><td><br>Photo " . $counter . ":<input name=' photo_filename[]' type='file' /><br></td></tr><tr></tr>";
$counter++;
}
$photo_upload_fields = $photo_upload_fields . "<input name='id' value='" . $row['id'] . "' />";
$photo_upload_fields = $photo_upload_fields . "</table><input type='submit' name='submit' value='Add Photos' />";