illuz1on Posted May 23, 2007 Share Posted May 23, 2007 Hey I have a form that sends to this being process.php, then sends to a success page.. It uploads 3 images, then at the success page adds some things into a DB... I want to pretty much do this in the sucess page, get the 3 uploaded files names and store them as $pic1-3 something like... $pic1 = "$_POST['name-of-upload-img-1']"; $pic2 = "$_POST['name-of-upload-img-2']"; $pic3 = "$_POST['name-of-upload-img-3']"; Dont know if thats right but any suggestions? <?php include "db-a.php"; $sqlsec = "SELECT * FROM sectionintros WHERE section='$section'"; $datasec = mysql_query($sqlsec); while($record = mysql_fetch_assoc($datasec)) { $id = $record['id']; $sections = $record['section']; $intro = $record['intro']; } ?> <?php // List Vars $sections="guidepro"; $headline="Guide Processing"; ?> <?php include "tophtml.php"; ?> <?php $directory_self = str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']); $uploadsDirectory = $_SERVER['DOCUMENT_ROOT'] . $directory_self . 'images/guides/'; $uploadForm = 'http://' . $_SERVER['HTTP_HOST'] . $directory_self . 'guide-form.php'; $uploadSuccess = 'http://' . $_SERVER['HTTP_HOST'] . $directory_self . 'guide-success.php'; $fieldname = 'file'; $errors = array(1 => 'php.ini max file size exceeded', 2 => 'html form max file size exceeded', 3 => 'file upload was only partial', 4 => 'no file was attached'); isset($_POST['submit']) or error('the upload form is neaded', $uploadForm); $active_keys = array(); foreach($_FILES[$fieldname]['name'] as $key => $filename) { if(!empty($filename)) { $active_keys[] = $key; } } count($active_keys) or error('No files were uploaded', $uploadForm); foreach($active_keys as $key) { ($_FILES[$fieldname]['error'][$key] == 0) or error($_FILES[$fieldname]['tmp_name'][$key].': '.$errors[$_FILES[$fieldname]['error'][$key]], $uploadForm); } foreach($active_keys as $key) { @is_uploaded_file($_FILES[$fieldname]['tmp_name'][$key]) or error($_FILES[$fieldname]['tmp_name'][$key].' not an HTTP upload', $uploadForm); } foreach($active_keys as $key) { @getimagesize($_FILES[$fieldname]['tmp_name'][$key]) or error($_FILES[$fieldname]['tmp_name'][$key].' not an image', $uploadForm); } foreach($active_keys as $key) { $now = time(); while(file_exists($uploadFilename[$key] = $uploadsDirectory.$now.'-'.$_FILES[$fieldname]['name'][$key])) { $now++; } } foreach($active_keys as $key) { @move_uploaded_file($_FILES[$fieldname]['tmp_name'][$key], $uploadFilename[$key]) or error('receiving directory insuffiecient permission', $uploadForm); } header('Location: ' . $uploadSuccess); function error($error, $location, $seconds = 5) { header("Refresh: $seconds; URL=\"$location\""); echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"'."\n". '"http://www.w3.org/TR/html4/strict.dtd">'."\n\n". '<html lang="en">'."\n". ' <head>'."\n". ' <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">'."\n\n". ' <link rel="stylesheet" type="text/css" href="stylesheet.css">'."\n\n". ' <title>Upload error</title>'."\n\n". ' </head>'."\n\n". ' <body>'."\n\n". ' <div id="Upload">'."\n\n". ' <h1>Upload failure</h1>'."\n\n". ' <p>An error has occured: '."\n\n". ' <span class="red">' . $error . '...</span>'."\n\n". ' The upload form is reloading</p>'."\n\n". ' </div>'."\n\n". '</html>'; exit; } ?> <?php include "btmhtml.php"; ?>\ Quote Link to comment https://forums.phpfreaks.com/topic/52734-image-upload-processing/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.