Forum Moderators: coopster

Message Too Old, No Replies

upload image problem

<input type=file problem

         

whizzy

3:20 am on Jun 24, 2003 (gmt 0)

10+ Year Member



I have a form that look like this:

<form action="upload.php" method="post" enctype="multipart/form-data">
<input type=file name="FileToUpload" value="">
<input type="hidden" name="MaxFileSize" value="64000">
<input type="submit" name="Submit" value="Submit">
<form>

and my upload.php page look like this:
if ($FileToUpload_type == 'image/gif') {
$type = '.gif';
}
if ($FileToUpload_type == 'image/pjpeg') {
$type = '.jpg';
}
if ($FileToUpload_type == 'image/x-png') {
$type = '.jpg';
}
$newfile = substr($FileToUpload, -9);
if($FileToUpload_name = '') {
print("No file was selected!");
}
elseif($FileToUpload_size > $MaxFileSize) {
print("The file to upload is too big");
}
else {

$query = "INSERT INTO photos (`handle`, `location`, `photodesc`)
VALUES ('".$_SESSION['handle']."','$newfile$type', 'ad')";
//$result = mysql_query($query,$db_object) or die("ERROR");
echo $query;
//move_uploaded_file($FileToUpload, "/full/path/on/your/server/images/$newfile$type");
}

When I try this I just get this error:
Notice: Undefined variable: FileToUpload_type in line 14...

How come it can't get the variable?

jatar_k

3:32 am on Jun 24, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



where exactly is the value coming from, or supposed to be coming from?

how about this for an example?
[ca2.php.net...]

if ($_FILES['FileToUpload']['type'] == "put_type_here") may work