Jump to content

Upload File Problem


june_c21

Recommended Posts

HI ,

 

When i try to upload file , it said "Sorry, there was a problem uploading your file."

Can someone let me know what is the problem  ?

 

<?php
include './includes/header.php';

for ($i=1;$i<11;$i++)
{
$id = $_GET ['id'];
$causes = $_POST ['causes'][$i];
if(empty($causes)) break;
$corrective_action = $_POST ['corrective_action'][$i];
  $name = $_POST ['name'][$i];
  $date = $_POST ['date'][$i];

  $completedate = $_POST ['completedate'][$i];
  $remarks = $_POST ['remarks'][$i];
   $status = $_POST ['status'];

$query= "INSERT INTO corrective_action( id, causes, corrective_action, name, date, completedate, remarks ) VALUES ('$id','$causes','$corrective_action','$name','$date','$completedate','$remarks') ";
$result = mysql_query($query,$dblink);




$query1= "UPDATE event SET status= '$status' where id=$id ";
$result1 = mysql_query($query1,$dblink);



$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;
}

//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.";
}
}

$file_id = 3 ; 

$query = "UPDATE corrective_action SET file_name = '$target' WHERE file_id=$file_id";
$result = mysql_query($query,$dblink);
$file_id ++ ;
}


?>

Link to comment
https://forums.phpfreaks.com/topic/196936-upload-file-problem/
Share on other sites

I am a simple soul and if I were you, I would put literals into the code and test only the line that you think is failing.

If that fails, then it must be a system problem.

 

If that works, then put a variable into the statement and test that. Print out the variable before you put it into the statement to make sure that the file name is correct.

Hope that is some help at least.

Link to comment
https://forums.phpfreaks.com/topic/196936-upload-file-problem/#findComment-1033904
Share on other sites

$_FILES['uploaded']['name'] does not exist due to one of the half-dozen or so possible upload errors and your code has very little error checking logic in it (and some of it is not doing anything such as the size check because the variable $uploaded_size is not being set by your code.)

 

See this other recent thread for some upload error checking logic to get you started - http://www.phpfreaks.com/forums/index.php/topic,292945.0.html

Link to comment
https://forums.phpfreaks.com/topic/196936-upload-file-problem/#findComment-1033921
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.