Notice: Undefined variable

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
am trying to create a a upload uploading files ok but i
recieve this message.

Notice: Undefined variable: uploaded_size in /home/fhlinux169/c/ on line 7

Notice: Undefined variable: uploaded_type in /home/fhlinux169/c/ on line 14

Notice: Undefined index: uploadedfile in /home/fhlinux169/c/ on line 32
The file has been uploaded

This is my script:: please help

$target = "upload/";
$target = $target . basename( $_FILES['uploaded']['name']) ;

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

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

//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
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
echo "The file ".
basename( $_FILES['uploadedfile']['name']). " has been uploaded";
echo "Sorry, there was a problem uploading your file.";

Re: Notice: Undefined variable

Quoted text here. Click to load it

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";

Re: Notice: Undefined variable

Reggie wrote:
Quoted text here. Click to load it

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:

So long, Ulf

  _(_p>   Ulf [Kado] Kadner

Site Timeline