hey..
i am trying to create simple file upload script…
have lil problem… i just want to check if files were selected and field were not left empty.. how can do that?
[CODE]<table width=”500″ border=”0″ align=”center” cellpadding=”0″ cellspacing=”1″ bgcolor=”#CCCCCC”>
<tr>
<form action=”multiple_upload_ac.php” method=”post” enctype=”multipart/form-data” name=”form1″ id=”form1″>
<td>
<table width=”100%” border=”0″ cellpadding=”3″ cellspacing=”1″ bgcolor=”#FFFFFF”>
<tr>
<td><strong>multiple Files Upload </strong></td>
</tr>
<tr>
<td>Select file
<input name=”ufile[]” type=”file” id=”ufile[]” size=”50″ /></td>
</tr>
<tr>
<td align=”center”><input type=”submit” name=”Submit” value=”Upload” /></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
[code=php]
<?php
$random1 = date(‘s’);
$random2 = date(‘G’);
$random3 = date(‘j’);
print “<br>”;
echo $random1;
print “<br>”;
echo $random2;
print “<br>”;
echo $random3;
print “<br>”;
$new = $random1 * $random2 * $random3;
print “<br>”;
echo $new;
print “<br>”;
mkdir (“uploads/$new”, 0777);
//set where you want to store files
//in this example we keep file in folder upload
//$HTTP_POST_FILES[‘ufile’][‘name’]; = upload file name
//for example upload file name cartoon.gif . $path will be upload/cartoon.gif
$path1= “uploads/$new/”.$HTTP_POST_FILES[‘ufile’][‘name’][0];
//copy file to where you want to store file
copy($HTTP_POST_FILES[‘ufile’][‘tmp_name’][0], $path1);
//$HTTP_POST_FILES[‘ufile’][‘name’] = file name
//$HTTP_POST_FILES[‘ufile’][‘size’] = file size
//$HTTP_POST_FILES[‘ufile’][‘type’] = type of file
echo “File Name :”.$HTTP_POST_FILES[‘ufile’][‘name’][0].”<BR/>”;
echo “File Size :”.$HTTP_POST_FILES[‘ufile’][‘size’][0].”<BR/>”;
echo “File Type :”.$HTTP_POST_FILES[‘ufile’][‘type’][0].”<BR/>”;
echo “<img src=”$path1″ width=”150″ height=”150″>”;
echo “<P>”;
// Use this code to display the error or success.
$filesize1=$HTTP_POST_FILES[‘ufile’][‘size’][0];
if($filesize1 != 0)
{
echo “We have recieved your files”;
}
else { echo “ERROR…..”; }
}
?>
thanks