Hi all, I need some help. I'm running an Apache server with Debian 2.4 and PHP Version 4.0.3pl1 .
Is there any reason why this code won't work for me?
I have a form as such:
<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function getCookie(name){
var cname = name + "=";
var dc = document.cookie;
if (dc.length > 0) {
begin = dc.indexOf(cname);
if (begin != -1) {
begin += cname.length;
end = dc.indexOf(";", begin);
if (end == -1) end = dc.length;
return unescape(dc.substring(begin, end));
}
}
return null;
}
function setCookie(name, value) {
var now = new Date();
var then = new Date(now.getTime() + 31536000000);
document.cookie = name + "=" + escape(value) + "; expires=" + then.toGMTString() + "; path=/";
}
function getInfo(form) {
form.info.value = "Browser Information: " + navigator.userAgent;
}
function getValue(element) {
var value = getCookie(element.name);
if (value != null) element.value = value;
}
function setValue(element) {
setCookie(element.name, element.value);
}
function fixElement(element, message) {
alert(message);
element.focus();
}
function isMailReady(form) {
var passed = false;
if (form.file.value == "") {
fixElement(form.file, "Please select the file you wish to upload.");
}
else {
getInfo(form);
passed = true;
}
return passed;
}
// End -->
</SCRIPT>
</head>
</body>
<form enctype="multipart/form-data" method="post" action="do_upload.php" onSubmit = "return isMailReady(this);">
<input type="file" name="file" size="50" onBlur = "setValue(this)">
<input type="submit" name="submit" value="Upload File" onFocus = "getValue(this)" onBlur = "setValue(this)">
</form>
</body>
The do_upload.php script looks like this:
<?
if ($file_name !="")
{
copy("$file", "/home/union/public_html/eepss/uploads/$RID.$FORMAT");
}
else
{
die ("No input file specified. Please use the Browse button to select the document you wish to upload");
}
?>