jamrop Posted May 24, 2008 Share Posted May 24, 2008 hey can anyone explain what i am doing wrong pls <? // you can change this to any directory you want // as long as php can write to it $uploadDir = '/public_html/image/'; for ($k=0; $k<count($_FILES['userfile']['name']); $k++) { if(isset($_POST['upload'])) { $fileName = $_FILES['userfile']['name'][$k]; $tmpName = $_FILES['userfile']['tmp_name'][$k]; $fileSize = $_FILES['userfile']['size'][$k]; $fileType = $_FILES['userfile']['type'][$k]; // the files will be saved in filePath $filePath = $uploadDir . $fileName; // move the files to the specified directory // if the upload directory is not writable or // something else went wrong $result will be false $result = move_uploaded_file($tmpName, $filePath[$k]); if (!$result) { echo "Error uploading file"; exit; } if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); $filePath = addslashes($filePath); } $query = "INSERT INTO image ( image, size, type, path) ". "VALUES ('$fileName', '$fileSize', '$fileType', '$filePath')"; mysql_query($query) or die('Error, query failed : ' . mysql_error()); echo "<br>File uploaded<br>"; } } ?> <form action="" method="post" enctype="multipart/form-data" name="uploadform"> <table width="350" border="0" cellpadding="1" cellspacing="1" class="box"> <tr> <td width="246"><input type="hidden" name="MAX_FILE_SIZE" value="2000000"><input name="userfile[]" type="file" class="box" id="userfile"> <input name="userfile[]" type="file" class="box" id="userfile"> <input name="userfile[]" type="file" class="box" id="userfile"> <input name="userfile[]" type="file" class="box" id="userfile"> <input name="userfile[]" type="file" class="box" id="userfile"> <input name="userfile[]" type="file" class="box" id="userfile"> <input name="userfile[]" type="file" class="box" id="userfile"> <input name="userfile[]" type="file" class="box" id="userfile"> <input name="userfile[]" type="file" class="box" id="userfile"> </td> <td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td> i get the error uploading file message Many many thanks Link to comment https://forums.phpfreaks.com/topic/107063-upload-images-loop/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.