Hi there,
I have uploaded an image to my computer from my computer, I'm working on an upload function. Everything works great, the file gets uploaded where it should but when I try to use it in a webpage it's a red x and when I try to open it with MS pic viewer it says no preview available... something must not have worked with my upload, the file size is as it should be though.
Do you think it's the code?
Here is my function:
function upload_single_file()
{
$uploaddir="c:\\Program files\\apache group\\apache2\\htdocs\\upload\\";
$uploadfile=$uploaddir.basename($_FILES['vlu']['name']);
if($_FILES['vlu']['error']== UPLOAD_ERR_OK)
{
if(move_uploaded_file($_FILES['vlu']['tmp_name'],$uploadfile))
{
print "file uploaded ok";
return 1;
}
else
{
print "file did not upload ok<br>";
return 0;
};
}
else
{
print "file error";
return 0;
}
}
Here is the HTML:
<?
print "<html>";
print "<body>";
include('file_functions.inc');
$form="<form method=\"post\" action=\"index.php\" enctype=\"multipart/form-data\">
<input type=\"hidden\" name=\"seenform\" value=\"y\">
<input type=\"file\" name=\"vlu\"><br>
<input type=\"submit\" value=\"submit\">
</form>";
if($_POST[seenform]=="y")
{
upload_single_file();
}
else
{
print $form;
}
print "</body>";
print "</html>";
?>
I have uploaded an image to my computer from my computer, I'm working on an upload function. Everything works great, the file gets uploaded where it should but when I try to use it in a webpage it's a red x and when I try to open it with MS pic viewer it says no preview available... something must not have worked with my upload, the file size is as it should be though.
Do you think it's the code?
Here is my function:
function upload_single_file()
{
$uploaddir="c:\\Program files\\apache group\\apache2\\htdocs\\upload\\";
$uploadfile=$uploaddir.basename($_FILES['vlu']['name']);
if($_FILES['vlu']['error']== UPLOAD_ERR_OK)
{
if(move_uploaded_file($_FILES['vlu']['tmp_name'],$uploadfile))
{
print "file uploaded ok";
return 1;
}
else
{
print "file did not upload ok<br>";
return 0;
};
}
else
{
print "file error";
return 0;
}
}
Here is the HTML:
<?
print "<html>";
print "<body>";
include('file_functions.inc');
$form="<form method=\"post\" action=\"index.php\" enctype=\"multipart/form-data\">
<input type=\"hidden\" name=\"seenform\" value=\"y\">
<input type=\"file\" name=\"vlu\"><br>
<input type=\"submit\" value=\"submit\">
</form>";
if($_POST[seenform]=="y")
{
upload_single_file();
}
else
{
print $form;
}
print "</body>";
print "</html>";
?>