By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,636 Members | 2,381 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,636 IT Pros & Developers. It's quick & easy.

Notice: Undefined variable

P: n/a
am trying to create a a upload file.am uploading files ok but i
recieve this message.

Notice: Undefined variable: uploaded_size in /home/fhlinux169/c/
clashoff.co.uk/user/htdocs/upload.php on line 7

Notice: Undefined variable: uploaded_type in /home/fhlinux169/c/
clashoff.co.uk/user/htdocs/upload.php on line 14

Notice: Undefined index: uploadedfile in /home/fhlinux169/c/
clashoff.co.uk/user/htdocs/upload.php on line 32
The file has been uploaded

This is my script:: please help

<?php
$target = "upload/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;

//This is our size condition
if ($uploaded_size 350000)
{
echo "Your file is too large.<br>";
$ok=0;
}

//This is our limit file type condition
if ($uploaded_type =="text/php")
{
echo "No PHP files<br>";
$ok=0;
}

//Here we check that $ok was not set to 0 by an error
if ($ok==0)
{
Echo "Sorry your file was not uploaded";
}

//If everything is ok we try to upload it
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ".
basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
?>

Aug 12 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Aug 12, 7:06 am, Reggie <joelregisfo...@hotmail.comwrote:
am trying to create a a upload file.am uploading files ok but i
recieve this message.

Notice: Undefined variable: uploaded_size in /home/fhlinux169/c/
clashoff.co.uk/user/htdocs/upload.php on line 7

Notice: Undefined variable: uploaded_type in /home/fhlinux169/c/
clashoff.co.uk/user/htdocs/upload.php on line 14

Notice: Undefined index: uploadedfile in /home/fhlinux169/c/
clashoff.co.uk/user/htdocs/upload.php on line 32
The file has been uploaded

This is my script:: please help

<?php
$target = "upload/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;

//This is our size condition
if ($uploaded_size 350000)
{
echo "Your file is too large.<br>";
$ok=0;

}

//This is our limit file type condition
if ($uploaded_type =="text/php")
{
echo "No PHP files<br>";
$ok=0;

}

//Here we check that $ok was not set to 0 by an error
if ($ok==0)
{
Echo "Sorry your file was not uploaded";

}

//If everything is ok we try to upload it
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ".
basename( $_FILES['uploadedfile']['name']). " has been uploaded";}

else
{
echo "Sorry, there was a problem uploading your file.";}
}

?>
Read your errors:

You need to initalize and fill your variables before you compare them
against something:

$upload_size = $_FILE['uploaded']['size'];
$upload_type = $_FILE['uploaded']['type'];
// assuming 'uploaded' is the name of your file

line 32 to should read:

basename( $_FILES['uploaded']['name']). " has been uploaded";
Aug 12 '07 #2

P: n/a
Reggie wrote:
Notice: Undefined variable: uploaded_size in /home/fhlinux169/c/
clashoff.co.uk/user/htdocs/upload.php on line 7
Remeber the Message, go to line 7 of youre Code
if ($uploaded_size 350000)
You access a variable $uploaded_size, undefined at this point.

Take a look at the manual. It easy to perform file-uploads with the
right code:
http://www.php.net/manual/en/features.file-upload.php

So long, Ulf

--
_,
_(_p Ulf [Kado] Kadner
\<_)
^^
Aug 12 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.