hi,
i'm working on a website where users can upload csv files and have it converted directly to a specific table in the sql db...
it was working fine at first, but now it seems to give me the following error:
Warning: file(./test.csv): failed to open stream: No such file or directory in ...
once the file (in this case test.csv) is selected to upload, the form sends it to a page called upload.php
i'm relatively new to php as im more experienced with jsp so my coding may not be the most efficient or the prettiest ... but anyways, here is some relevant code from upload.php:
//upload file
$target = "docs/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
$filename = "./".basename( $_FILES['uploaded']['name']) ;
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.";
}
//add values to table
$fcontents = file ($filename);
for($i=0; $i<sizeof($fcontents); $i++) {
$line = trim($fcontents[$i]);
$arr = explode(",", $line);
$sql = "insert into portfolio values ('".
implode("','", $arr) ."')";
mysql_query($sql);
echo $sql ."<br>";
if(mysql_error()) {
echo mysql_error();
}
}
any help would be appreciated!
Cheers