Hi I have the following saved as upload.php.
<html>
<head>
</head>
<body>
<?php
for($file_count = 0; $file_count <= count($_FILES['files']['tmp_name']); $file_count++){
echo '111111';
if( $_FILES['files']['error'][$file_count] == 0){
echo '2222222222';
$target_dir = "uploads/".time().$_FILES['files']['name'][$file_count];
echo '333333333333';
move_uploaded_file($_FILES['files']['tmp_name'][$file_count], $target_dir);
echo '4444444444444';
}
}
?>
<div>
<form method="post" name="upload_form" enctype="multipart/form-data"
action="">
<input type="file" name="files[]" enctype="form/multipart"> <input
type="submit" id="photo_upload" value="Upload Photo...">
</form>
<div id="contents">fggfgfg</div>
</div>
</body>
</html>
The upload works fine. The problem is when I launch the page, I see error messages. (Can't upload screenshots to show them).
To avoid them I tried checking if the form was set in the post request like so: if(isset($_POST[])).
But when I have the above if block, the code inside it does'nt get executed even when I select and submit the files.
How can I get around this.
QUESTION 2:
Can somebody please point me to jquery based file upload example? I have to asynchrously upload files since there are other form field available on the page.