RCS Posted April 13, 2008 Share Posted April 13, 2008 I created this post at an attempt to explain my problem better. I created an upload form with these fields make, description, price, picture. The form then submits the information to the databse for me to call and display on a catalog page. The script is working great but now the issue I'm having is that I would like to be able to upload not just one file to database but ten using the same script. What is the easiest way to change the script to allow ten upload and not just one. Here is a sample of my script. The Form <form action="upload_file.php" method="POST" enctype="multipart/form-data"> <p align="center"> </p> <p> <label><strong>Id:</strong> <!----- INPUT FIELD FOR ID ---> <input name="id" type="text" id="id" size="2" maxlength="2"> </label> (Pick id number 1 through 10) <p><label><b>Make:</b></label> <!----- INPUT FIELD FOR MAKE OF PRODUCT---> <input type="text" name="make" id="make" /></p> <p><label><b>Price:</b></label> <input type="text" name="price" id="price" /></p> <!----- INPUT FIELD FOR PRICE ---> <p><label></label> <label><b>Description:</b></label> <textarea name="description" id="description" cols="45" rows="5"></textarea /><!----- INPUT FIELD FOR DESCRIPTION ---> </p> <p><p><label for="file"><strong>Filename:</strong></label> <input type="file" name="file" id="file" /> <!----- INPUT FIELD FOR IMAGE ---> <input type="hidden" name="MAX_FILE_SIZE" value="100000000000000"> <strong>(Note pictures must be sized to 182 X 124 pixels)</strong></p> </p> <input type="submit" name="submit" value="Save" /> </form> File Array .INC File $fileName = $_FILES['file']['name']; <!----- name of image ---> $tmpName = $_FILES['file']['tmpName'];<!----- Temp Directory----> $fileSize = $_FILES['file']['size']; <!----- File Size ---------> $fileType = $_FILES['file']['type']; <!----- File type-----> Upload script $fileName = $_FILES['file']['name']; $tmpName = $_FILES['file']['tmpName']; $fileSize = $_FILES['file']['size']; $fileType = $_FILES['file']['type']; if ((($_FILES["file"]["type"] == "image/gif") <!----- File types allowed-----> || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/jpg") || ($_FILES["file"]["type"] == "image/png") || ($_FILES["file"]["type"] == "image/tif") || ($_FILES["file"]["type"] == "image/psd") || ($_FILES["file"]["type"] == "image/bmp") || ($_FILES["file"]["type"] == "image/pct") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 200000000000)) <!----- Max File Size-----> { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; Link to comment https://forums.phpfreaks.com/topic/100878-phpmysql-upload/ Share on other sites More sharing options...
Barand Posted April 13, 2008 Share Posted April 13, 2008 1 ) Use code tags as you were told in your other post on this topic. 2 ) Don't double post. Topic closed. Link to comment https://forums.phpfreaks.com/topic/100878-phpmysql-upload/#findComment-515915 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.