Jump to content

Need some help with uploading multiple image files


simcoweb

Recommended Posts

I have code for uploading a single file and then inserting that file name into the mysql database. What I need some help with is uploading 3 images at once and how i'd modify the code accordingly in order to coordinate the form with the upload script. Here's what I have for a single upload:

 

<?
if(isset($_POST['upload'])
    {
        $ServerRoot = $_SERVER['DOCUMENT_ROOT'];  // Grabs the home directory of                                        your hosting.
        $Directory = 'uploads/';  // Folder that will be uploaded to relative to the public_html.
        $MaxFileSize = '10240';  // Maximum file size allowed.
        $AllowedFiles = array(jpg,gif,png,psd,zip,rar,bmp); // The allowed file extensions
        $FileExtension = $_FILES['file']['type'];
        $FileSize = $_FILES['file']['size'];
        $FileName = $_FILES['file']['name'];
        if($FileSize > $MaxFileSize)
        {
        echo 'Your file is too big!';
        exit;
        }
    if(!in_array($FileType)
        {
        echo 'You are not allowed to upload that file type!';
        exit;
        }
    $UploadFile = move_uploaded_file($_FILES['file']['tmp_name'], $ServerRoot$Directory);

        if($UploadFile !== TRUE)
        {
        echo 'Problem uploading!';
        exit;
        }

        echo "File uploaded successfully: http://www.your-domain/'.$Directory$_FILES['file']['name'].";
        
} else {
echo "
<form name='upload' encrypte='multipart/form-data' action="'.$_SERVER['PHP_SELF'].'" method='post'>
";
echo "<input type='upload' name='file' size='30' />";
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.