Hello friends, Please help me to sort out my problem , actually it is strange one and don't know why it appears.
Actually I was trying to make a file upload form which I got success although a bit. A bit in the sense, if I include just <form> in the body tag it works, but if i include some more Html along with it stops working ? Have anyone gone through same problem. Please someone helps me out.
This is the code snippet :-
<?php
if(isset($_POST['submit'])) {
echo "<pre>";
print_r($_FILES);
echo "</pre><br />";
if($_FILES['file']['error'] == 0) {
echo "File uploaded successfully";
} else {
echo "File not uploaded check it again";
}
echo $_FILES['file']['name'];
echo "<br />".$_FILES['file']['tmp_name'];
echo "<br /><hr /> ";
/// NOw to move the files to the the server
$target = "/var/www/php_sandbox/";
$target = $target.basename($_FILES['file']['name']);
$ok = 1;
if(!file_exists($target)) {
if(move_uploaded_file($_FILES['file']['tmp_name'],$target)) {
echo "The file at ".$_FILES['file']['tmp_name']." moved successfully ";
header("Location: index.php");
exit(1);
} else {
echo "Sorry there was probleming uploading files. PLease resolve it soon. :)";
}
} else {
echo "Files already exists \n";
}
}
?>
<form id="fileUpload" action="" method="post" enctype="multipart/form-data" >
<label for="file">File :</label>
<input type="file" name="file">
<br />
<input name="submit" type="submit" value="Submit Data">
</form>