Coding help
Posted: Sun May 22, 2005 8:14 pm
I have a form in which sends images from an upload browse field to a folder named /uploads. There is an if statement that I have that places the url of the image into a MySQL field. The if statement works well for one image (I have it on picture 5 at this time) but if I copy it over and change the filds to the appropriate picture, I get an error. I need some sort of constructs to make it work. Anyone have an idea.
d11wtq | Please read the sticky about posting code in the forums 
Code: Select all
// The upload configuration
// NOTE: You dont have to set every value!
// Like below, we have not set the "size", so the default configuration
// value is used (max size which is possible).
$cfg = array(
"path" => $_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['PHP_SELF']).'/uploads/',
"type" => "jpg jpeg",
"name" => "picture1", // <-- keep the original name
"required" => true,
"exists" => "rename"
);
// upload field
$form->uploadField("Great! Now load your pictures. Hit the browse button and it will take you to where ever you saved your picture at on the computer. Your front screen, when you turn on your computer, is called the desktop. If you can see your pic icons there, then use the browse to find your pic under desktop. If they are on disk, again, go to D:/(or the appropriate drive) via brouse and you can attach them from there. My Documents may be another common place they would be.", "picture1", $cfg);
// The upload configuration
// NOTE: You dont have to set every value!
// Like below, we have not set the "size", so the default configuration
// value is used (max size which is possible).
$cfg = array(
"path" => $_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['PHP_SELF']).'/uploads/',
"type" => "jpg jpeg",
"name" => "picture2", // <-- keep the original name
"required" => true,
"exists" => "rename"
);
// upload field
$form->uploadField("Upload your second picture", "picture2", $cfg);
// The upload configuration
// NOTE: You dont have to set every value!
// Like below, we have not set the "size", so the default configuration
// value is used (max size which is possible).
$cfg = array(
"path" => $_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['PHP_SELF']).'/uploads/',
"type" => "jpg jpeg",
"name" => "picture3", // <-- keep the original name
"required" => true,
"exists" => "rename"
);
// upload field
$form->uploadField("Upload your third picture", "picture3", $cfg);
// The upload configuration
// NOTE: You dont have to set every value!
// Like below, we have not set the "size", so the default configuration
// value is used (max size which is possible).
$cfg = array(
"path" => $_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['PHP_SELF']).'/uploads/',
"type" => "jpg jpeg",
"name" => "picture4", // <-- keep the original name
"required" => true,
"exists" => "rename"
);
// upload field
$form->uploadField("Upload your forth picture", "picture4", $cfg);
// The upload configuration
// NOTE: You dont have to set every value!
// Like below, we have not set the "size", so the default configuration
// value is used (max size which is possible).
$cfg = array(
"path" => $_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['PHP_SELF']).'/uploads/',
"type" => "jpg jpeg",
"name" => "picture5", // <-- keep the original name
"required" => true,
"exists" => "rename"
);
// upload field
$form->uploadField("Upload your fifth picture", "picture5", $cfg);
if( $form->value("picture5") != '') {
$form->addValue( "picture5", "/uploads/".$form->value("picture5") );
}
// submitbutton beneath it
$form->SubmitButton("Submit"); // the options
// set the 'commit after form' function
$form->onCorrect("doRun");
// send the form to the screen
$form->Flush();
// function to show a message
function doRun($data) {
return "Hello ". $data["name"];
}
?>
</form>