Проблем с File upload script

rozovotoponi

Registered
Къде е грешката?

upload.html

Код:
<form enctype="multipart/form-data" action="upload.php" method="POST">
Please choose a file: <input name="uploaded" type="file" /><br />
<input type="submit" value="Upload" />
</form>

upload.php

Код:
<?php
$target = "/img";
$target = $target . basename( $_FILES['uploaded']['imgup']) ;
$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 =="image/jpg")
{
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']['imgup'], $target))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
?>
 
Пробвай така:

Код:
<form enctype="multipart/form-data" action="upload.php" method="POST"> 
Please choose a file: <input name="uploaded" type="file" /></br>
<input type="submit" value="Upload" /> 
</form>
 
<?php
$target = "/img";
//$target = $target . basename( $_FILES['uploaded']['imgup']) ; - няма такъв аргумент в масива!!!
$target = $target . basename( $_FILES['uploaded']['name') ;
$ok=1;

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

//This is our limit file type condition
if ($_FILES['uploaded']['type'] =="image/jpg")
{
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['uploaded']['name']). " has been uploaded";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
?>
 

Back
Горе