simcoweb Posted February 24, 2007 Share Posted February 24, 2007 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' />"; } ?> Quote Link to comment 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.