Hello. I have a php file with a form on it. the form has a few text fields and a few file fields. The problem is that for some weird reason the file upload fields screw everything up.
After I press submit, it carries NO data to the fallowing page. But when I troubleshot, I took out the file fields, and everything worked fine. (Except only I cant upload files)
Here is the form...
video_adder.php
<form name="vid_form" method="post" enctype="multipart/form-data" action="$PHP_SELF"><br>
<input type="hidden" name="admin_action" value="submit_new">
Video title: <input type="text" size="20" maxlength="25" name="form_title"><br /><br>
Description: <TEXTAREA name="form_desc" cols=30 rows=4 maxlength="190"></TEXTAREA><br><br>
Flv file: <input name="flv_file" type="file" /><br><br>
Mp4 file: <input name="mp4_file" type="file" /><br><br>
Jpg screenshot: <input name="jpg_file" type="file" /><br><br>
<input type="submit" value="Upload Video!" />
Then here is the script that retrieves the data (note that we check if "admin_action" has a value)
video_adder.php
$admin_action = $_POST['admin_action'];
if($admin_action != NULL){
$form_title = $_POST['form_title'];
$form_desc = $_POST['form_desc'];
$target_path = $_POST['form_target'];
$target_path2 = $_POST['form_target'];
$target_path3 = $_POST['form_target'];
//upload flv file
$target_path = $target_path . basename( $_FILES['flv_file']['name']);
if(move_uploaded_file($_FILES['flv_file']['tmp_name'], $target_path)) {
$err_check[1] = "SUCCESS";
} else{ $err_check[1] = "FAILED"; }
//upload mp4 file
$target_path2 = $target_path2 . basename( $_FILES['mp4_file']['name']);
if(move_uploaded_file($_FILES['mp4_file']['tmp_name'], $target_path2)) {
$err_check[2] = "SUCCESS";
} else{ $err_check[2] = "FAILED"; }
//upload jpg screenshot
$target_path3 = $target_path3 . basename( $_FILES['jpg_file']['name']);
if(move_uploaded_file($_FILES['jpg_file']['tmp_name'], $target_path3)) {
$err_check[3] = "SUCCESS";
} else{ $err_check[3] = "FAILED"; }
//put in mysql data
$result = mysql_query("INSERT INTO `videos` (`name`,`description`)VALUES ('$form_title', '$form_desc')");
}
So when I run this code, fill in the form, and click upload, $admin_action is coming up NULL which means none of the form data is getting passed. But again, when I troubleshoot and take out the upload fields, $admin_action and all the other form data passes through just fine.
So any ideas? I've been working on this for days. Thanks!