Pls help me find the problem.
All input fields work except for the upload.
It doesnt take the file to directory I want.
I have error scripts in case there's an error
but alert errors are not popping, I dont know why... Help...

if(isset($_POST['submit'])) {
        $upload_errors = array(
          UPLOAD_ERR_OK 		=> "No errors.",
          UPLOAD_ERR_INI_SIZE  	=> "Larger than upload_max_filesize.",
          UPLOAD_ERR_FORM_SIZE 	=> "Larger than form MAX_FILE_SIZE.",
          UPLOAD_ERR_PARTIAL 	=> "Partial upload.",
          UPLOAD_ERR_NO_FILE 	=> "No file.",
          UPLOAD_ERR_NO_TMP_DIR => "No temporary directory.",
          UPLOAD_ERR_CANT_WRITE => "Can't write to disk.",
          UPLOAD_ERR_EXTENSION 	=> "File upload stopped by extension."
          $tmp_file = $_FILES['file_upload']['tmp_name'];
          $target_file = basename($_FILES['file_upload']['name']);
          $upload_dir = "admin/tourdocs";
          $file_type = $_FILES['file_upload']['type']; 

			$tourId = mysql_prep($_POST['tourId']);
			$tourName = mysql_prep($_POST['tourName']);
			$destination = mysql_prep($_POST['destination']);
			$date = mysql_prep($_POST['date']);
			$amount = mysql_prep($_POST['amount']);
			$subject = mysql_prep($_POST['subject']);
			$classCode = mysql_prep($_POST['classCode']);
			$section = mysql_prep($_POST['section']);
			$teacher = mysql_prep($_POST['teacher']);
			$upload_dir = mysql_prep($upload_dir);
			$path =  $upload_dir. "/".$target_file; 
						$query = " INSERT INTO tbl_tour_profile ( 
								 `tour_code`, `tour_name`, `subj_code`, `subj_name`,  
								 `section`, `subj_teacher`, `destination`, `date`,  
								 `path`, `tour_amount`) 
									VALUES (
								'$tourId', '{$tourName}', {$classCode}, '{$subject}',   
								'{$section}', '{$teacher}', '{$destination}', {$date}, 
								'{$path}', '{$amount}')";
						$result = mysql_query($query);
						if ($result) {
						$message = "File successfully uploaded to:  " . $path ;
							if(move_uploaded_file($tmp_file, $path)) {
								$message = "File successfully uploaded to:  " . $path ;
								alert_msg ($message);
							else {
								$error = $_FILES['file_upload']['error'];
								$message = $upload_errors[$error] ; 
alert_msg ($message);
						else {
							echo "<p>Failed.</p>";
							echo "<p>" . mysql_error() . "</p>";

			//or the file is no image		


 if(!empty($message)) { $message = $tourId; alert_msg( $message ); } 

<form id="createTourForm" name="createTourForm" method="post" action="admin_tour_createtour.php">

<p><label id='createTourForm_tourId_errorloc' class="error_strings"></label></p>
       <label ><h3>Tour Id</h3></label>
       <input name="tourId" type="text" class="text" id="tourId"   
        value="<?php echo $id ;?>"  readonly="readonly"
        onfocus="clearIt(this)" onblur="setIt(this)" >    <br />   

<table border=0 > <tr><td>
<p><label id='createTourForm_tourName_errorloc' class="error_strings"></label></p>
       <label ><h3>Tour Name</h3></label>
       <input name="tourName" type="text" class="text" id="tourName" 
        onfocus="clearIt(this)" onblur="setIt(this)" >           
<p><label id='createTourForm_destination_errorloc' class="error_strings"></label></p>
       <label ><h3>Destination</h3></label>
       <input name="destination" type="text" class="text" id="destination" 
        onfocus="clearIt(this)" onblur="setIt(this)" >           
<p><label id='createTourForm_date_errorloc' class="error_strings"></label></p> 
       <label ><h3>Tour Date</h3></label>
       <input name="date" type="text" class="text" id="date" 
        onfocus="clearIt(this)" onblur="setIt(this)" >   
                <p><label id='createTourForm_amount_errorloc' class="error_strings"></label></p> 
                       <label ><h3>Tour Amount</h3></label>
                       <input name="amount" type="text" class="text" id="amount" 
                        onfocus="clearIt(this)" onblur="setIt(this)" >   
                <td><label>Subject Name: </label></td>
                <td><h2><?php  echo $subjectName; ?></h2></td>
                <td><label>Subject Code: </label></td>
                <td><h2><?php  echo $subjectCode; ?></h2></td>
                <td><label>Section: </label></td>
                <td><h2><?php  echo $section; ?></h2></td>
                <td><label>Teacher: </label></td>
                <td><h2><?php  echo $teacher; ?></h2></td>
<label><h3>Upload Tour Document</h3></label>              
       <input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
       <input type="file" name="file_upload" />  <br /> 

       <br /><br /><input type="submit" name="submit" value="Create Profile" />
<input name="classCode" type="hidden" class="text" value ="<?php  echo $subjectCode; ?>" >
<input name="subject" type="hidden" class="text" value ="<?php  echo $subjectName; ?>" >   
<input name="section" type="hidden" class="text" value ="<?php  echo $section; ?>" >
<input name="teacher" type="hidden" class="text" value ="<?php  echo $teacher; ?>" >           

5 Years
Discussion Span
Last Post by adkhan

If your form include an <input type="file" ...> element, then you must use

<form id="createTourForm" name="createTourForm" method="post" action="admin_tour_createtour.php" enctype="multipart/form-data">

Hope this helps!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.