tomjung09 Posted April 30, 2009 Share Posted April 30, 2009 My $_File array is empty and therefore I cannot upload images. It just stopped working, I have no Idea what I did. This is the form tag: <form id="pleasework" name="pleasework" method="post" action="uploadbikesubmit.php" enctype="multipart/form-data"> <input type="file" name="txtimage1"/> And the code I am using to upload it is this: <?php require_once 'salvagedrides.php'; mysql_select_db($database_sr, $sr); session_start(); //$username = $_SESSION['$user_ID']; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <style type="text/css"> <!-- body { background-color: #D7DFEC; } .style1 {color: #00757E} .style2 {font-size: 12px} .style3 {font-size: 18px} --> </style></head> <body> <table width="699" border="0" cellpadding="0" cellspacing="0"> <!--DWLayoutTable--> <tr> <td width="210" height="107"> </td> <td width="454"> </td> <td width="35"> </td> </tr> <tr> <td height="267"> </td> <td valign="top" bgcolor="#CC3300"><?php $model = $_POST['txtmodel']; $year = $_POST['txtyear']; $make = $_POST['txtmake']; $bid = $_POST['txtbid']; $location = $_POST['txtlocation']; $zipcode = $_POST['txtzipcode']; $enddate = $_POST['txtenddate']; $actualenddate = $_POST['txtactualenddate']; $comments = $_POST['txtcomments']; $vin = $_POST['txtvin']; $engine = $_POST['txtengine']; $title = $_POST['txttitle']; $milage = $_POST['txtmilage']; $status = $_POST['txtstatus']; $location = $_POST['txtlocation']; $category = $_POST['txtcategory']; $keys = $_POST['txtkeys']; $featured = $_POST['txtfeatured']; //make sure all required fields are filled if($model == ""){header("Location: uploadbike.php?msg=model" . $back);} /* elseif($year == ""){header("Location: uploadbike.php?msg=year" . $back);} elseif($make == ""){header("Location: uploadbike.php?msg=make" . $back);} elseif($bid == ""){header("Location: uploadbike.php?msg=bid" . $back);} elseif($location == ""){header("Location: uploadbike.php?msg=location" . $back);} elseif($zipcode == ""){header("Location: uploadbike.php?msg=zipcode" . $back);} elseif($enddate == ""){header("Location: uploadbike.php?msg=enddate" . $back);} elseif($actualenddate == ""){header("Location: uploadbike.php?msg=actual" . $back);} elseif($_FILES['txtimage1']['name'] == ""){header("Location: uploadbike.php?msg=image1" . $back);} elseif($_FILES['txtimage2']['name'] == ""){header("Location: uploadbike.php?msg=image2" . $back);} elseif($_FILES['txtimage3']['name'] == ""){header("Location: uploadbike.php?msg=image3" . $back);} elseif($_FILES['txtimage4']['name'] == ""){header("Location: uploadbike.php?msg=image4" . $back);} elseif($_FILES['txtimage5']['name'] == ""){header("Location: uploadbike.php?msg=image6" . $back);} elseif($_FILES['txtimage6']['name'] == ""){header("Location: uploadbike.php?msg=image7" . $back);} elseif($_FILES['txtimage7']['name'] == ""){header("Location: uploadbike.php?msg=image8" . $back);} elseif($_FILES['txtimage8']['name'] == ""){header("Location: uploadbike.php?msg=image9" . $back);}*/ else{ //check dates $enddate = substr($enddate, 0, 4) . substr($enddate, 5, 2) . substr($enddate, 8, 2) . substr($enddate, 11, 2) . substr($enddate, 14, 2); $actualenddate = substr($actualenddate, 0, 4) . substr($actualenddate, 5, 2) . substr($actualenddate, 8, 2) . substr($actualenddate, 11, 2) . substr($actualenddate, 14, 2); $date = date("YmdHis"); $str[0] = strtolower($_FILES['txtimage1']['name']); $str[1] = strtolower($_FILES['txtimage2']['name']); $str[2] = strtolower($_FILES['txtimage3']['name']); $str[3] = strtolower($_FILES['txtimage4']['name']); $str[4] = strtolower($_FILES['txtimage5']['name']); $str[5] = strtolower($_FILES['txtimage6']['name']); $str[6] = strtolower($_FILES['txtimage7']['name']); $str[7] = strtolower($_FILES['txtimage8']['name']); $str[8] = strtolower($_FILES['txtimage0']['name']); for($x = 0; $x < 9; $x += 1){ //not closed yet $i = strrpos($str[$x],"."); $l = strlen($str[$x]) - $i; $ext = substr($str[$x],$i+1,$l); echo "loop"; $path[$x] = "bike_images/" . $date . $x .".". $ext; } //end for loop $image_thumb = $path[8]; if ($_FILES["txtimage1"]["error"] > 0) { echo "Error: " . $_FILES["txtimage1"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["txtimage1"]["name"] . "<br />"; echo "Type: " . $_FILES["txtimage1"]["type"] . "<br />"; echo "Size: " . ($_FILES["txtimage1"]["size"] / 1024) . " Kb<br />"; echo "Stored in: " . $_FILES["txtimage1"]["tmp_name"]; } move_uploaded_file($_FILES["txtimage1"]["tmp_name"], $path[0]); move_uploaded_file($_FILES['txtimage2']['tmp_name'], $path[1]); move_uploaded_file($_FILES['txtimage3']['tmp_name'], $path[2]); move_uploaded_file($_FILES['txtimage4']['tmp_name'], $path[3]); move_uploaded_file($_FILES['txtimage5']['tmp_name'], $path[4]); move_uploaded_file($_FILES['txtimage6']['tmp_name'], $path[5]); move_uploaded_file($_FILES['txtimage7']['tmp_name'], $path[6]); move_uploaded_file($_FILES['txtimage8']['tmp_name'], $path[7]); move_uploaded_file($_FILES['txtimage0']['tmp_name'], $path[8]); } ?> </td> <td> </td> </tr> <tr> <td height="126"> </td> <td> </td> <td> </td> </tr> </table> </body> </html> I am getting an Error: 7 from the part that checks for errors for txtimage1 - I'm pretty sure that means that the $_file array is empty. I have checked my folder settings, its 777. And the only thing I'm not sure about is my upload_tmp_dir in my ini file. Its set to /tmp/ and I have a folder under my root site folder named tmp. Any ideas? Link to comment https://forums.phpfreaks.com/topic/156318-_file-array-is-empty/ Share on other sites More sharing options...
tomjung09 Posted April 30, 2009 Author Share Posted April 30, 2009 Ok, this isn't making sense, I changed upload_tmp_dir to "/tmp" and it worked. I made a small edit in my code (the part that does the upload not the one that posts the information) and it did not work again. I rolled back to the previous version that worked and it still does not work. This is frustrating. >.< Link to comment https://forums.phpfreaks.com/topic/156318-_file-array-is-empty/#findComment-823028 Share on other sites More sharing options...
tomjung09 Posted April 30, 2009 Author Share Posted April 30, 2009 Okay, $_file is not empty but ["tmp_name"] is empty. Still can't figure out why... Link to comment https://forums.phpfreaks.com/topic/156318-_file-array-is-empty/#findComment-823037 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.