help with upload script and form
Posted: Tue Feb 21, 2006 3:22 pm
I cant figure this out for nothing I have a form like this...the problem is the result always says No File Selected.
this form submit to a script with this code in it...
Code: Select all
<form action="contactprocess.php" method="post" multipart/form-data>
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
<input type="hidden" name="ip" value="70.118.40.221" />
<input type="hidden" name="httpref" value="http://www.projectmyspace.com/" />
<input type="hidden" name="httpagent" value="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; {D83082F7-1067-4A79-8193-4B40EEDCC689}; .NET CLR 1.1.4322; .NET CLR 2.0.50727)" />
<input type="hidden" name="subject" value="featured" />
<table width="100%" border="0">
<tr>
<td width="29%">Name:</td>
<td width="37%"><input type="text" name="visitor" value="jason"></td>
</tr>
<tr>
<td>Myspace Friend ID:</td>
<td><input type="text" name="friendId" value="29121987"></td>
</tr>
<tr>
<td> PayPal Email:</td>
<td><input type="text" name="visitormail" value="fgf@dfd.com"></td>
</tr>
<input type="hidden" name="message" value="none" />
<tr>
<td>Image to use</td>
<td><input type='file' name='file1' ONchange="preview(myimga,file1);" />
<input type='hidden' name='num' value='1'></td>
</tr>
<tr>
<td>Image Preview</td>
<td><span class="imgborder"><img alt="preview" border="0" width="150" name="myimga" src="cannotshow.gif" /></span></td>
</tr>
<tr>
<td> </td>
<td></td>
</tr>
<tr>
<td colspan="2">
<input name="Send" type="submit" value=" Continue ">
</td>
</tr>
<tr>
<td> </td>
<td></td>
</tr>
<tr>
<td> </td>
<td></td>
</tr>
</table>
</form>this form submit to a script with this code in it...
Code: Select all
// Start Upload section
if ($imsg<>"") echo $imsg . "<BR>";
$visitor = $_POST['visitor'];
$uploadDir = 'featured/uploads/';
$time = time();
$today = date("mdy");
$filePrefix = $_POST['friendId'] . '_' . $visitor . '_' . $time . '_' . $today . '_';
$num = $_POST['num'];
for ($x = 1; $x <= $num; $x++) {
// Make sure a file has been selected for upload
if (is_uploaded_file($_FILES['file'.$x]['tmp_name'])) {
$isImg = eregi('.*\.(jpg|jpeg|gif|png)',$_FILES['file'.$x]['name']);
// Get the size of the current file
$size = $_FILES['file'.$x]['size'];
// Make sure that this file is <= to 100KB
if ($size <= 500000 && $isImg) {
// get current time to use for filenames
//$time = time();
// Move the uploaded file
// here we apply the time to the filename but all add the current upload file number
// this will solve the problem if two or more files are processed in the same second
// username is kept for easier identification
// new wmw 12/17/04
echo "<br>";
$new_name = $_FILES['file' . $x]['name'];
//$new_name = preg_replace(array('/', '\\', '\'', '"'), array("","","",""), $new_name);
if (move_uploaded_file($_FILES['file'.$x]['tmp_name'],$uploadDir.'/' . $filePrefix . $new_name)) {
$uploadCount++;
echo "
<table width='100%' border='0' cellspacing='0' cellpadding='1'>
<tr bgcolor='F0F0F0'>
<td>
<img src='" . $uploadDir.'/' . $filePrefix . $new_name . "' width='175' border='0'>
</td>
</tr>
</table>
<br>";
// Store log details -- Will be sent by email
$upload_exists = 1;
$upload_log .= "<img src='http://www.projectmyspace.com/signs/$uploadDir/". $filePrefix . $new_name . "'> was uploaded.\nThis file will need to be approved before it will appear.";
// Change some permissions
chmod($uploadDir.'/' . $filePrefix . $new_name ,0777);
} else {
// Unable to move file
echo "File: ".$uploadDir.'/' . $filePrefix . $new_name . " error moving file.<BR>";
}
} else {
// File too large
echo "File: ".$uploadDir.'/' . $filePrefix . $new_name . "File Too Large.<BR>";
}
} else {
// No file selected
echo "No File Selected.<BR>";
}
} //End of loop
// End Upload section