Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image uploaded with script will not work display

Status
Not open for further replies.

SuaveRick

Programmer
Apr 12, 2004
142
CA
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>";
?>
 
It was a permissions problem, logged in with a higher admin account and it worked great.

FYI
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top