Forum Moderators: coopster
what is wrong with my code?
<?php>
echo ($HTTP_POST_FILES['thefile']['name']);
$file_realname = trim($HTTP_POST_FILES['thefile']['name']);
$uploaddir = "/images/";
if (move_uploaded_file($HTTP_POST_FILES['thefile']['tmp_name'], $uploaddir . $file_realname)) {
} else {
print "<strong>$file_realname</strong> did not upload!";
}
?>
The code above is called from a ASP page but I seem to lose the file in translation. What am I doing wrong. Why won't the code upload the image from an ASP form?
Also, is it possible to follow this path: ASP(FORM) -> JS(XMLHTTPREQUEST) -> PHP(UPLOAD FUNCTION)
I am attempting to refresh part of the page.
Thanks for you help.
Try the following, first, and see what it gives you. Put this at the top of this script:
echo '<pre>'; print_r($_FILES); echo '</pre>';
exit;
You must upload a smaller file or increase the max_file_size in the form.
function updateImg(action, uID, param1)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var filename = document.form1.whatsit.value;//Image Name
alert (filename);
var url="test.php"
url=url+"?action="+action
url=url+"&username="+uID
url=url+"¶m1="+param1
//url=url+"¶m2="+param2
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
when I run this script, with the code you gave me, it get the following:
Array
(
)
Is this not possible? To go from Embedded JS in ASP to PHP.