Whenever i try to upload a file using this script (below) it always comes back with the error:
"Warning: copy(N:\Computing\Computing Project\Analysis.doc) [function.copy]: failed to create stream: No such file or directory in D:\Sites\jwdesign\includes\admin\upload.php on line 37
Upload failed"
However i can upload things if i am on the server on which it is hosted on, but not from any other computers.
Can some one please have a look at the code and try to ammend it for me. Thanks.
<?php
if ($_POST['upload_action']=='Upload') {
$ext = substr_count($_POST['fileupload'],".") ? eregi_replace(".+\.([a-z0-9]+)","\\1",$_POST['fileupload']) : "";
if (empty ($_POST['file'])) {$_POST['file']='0';}
if ($_POST['file']=='verify') {
if (file_exists($path . $_POST['dir'] . $_POST['name'] . "." . $ext))
{ ?>The file already exists. <br><form action="<?php echo("$ip"); ?>/index.php?id=10&action=admin&admin_action=upload" method="post" enctype="application/x-www-form-urlencoded">
<input name="fileupload" type="hidden" value="<?php echo $_POST['fileupload']; ?>">
<input name="upload_action" type="hidden" value="Upload">
<input name="dir" type="hidden" value="<?php echo $_POST['dir']; ?>">
<input name="name" type="hidden" value="<?php echo $_POST['name']; ?>">
<input name="veraction" type="submit" value="Continue"></form>
<?php
}
else {$_POST['veraction']="Continue"; }
}
if (empty ($_POST['veraction'])) {$_POST['veraction']='0';}
if ($_POST['veraction']=='Continue') {
$res = copy($_POST['fileupload'], $path . $_POST['dir'] . $_POST['name'] . "." . $ext);
if (!$res) {echo ("Upload failed");}
else { ?>
<span class="maintext">The file was uploaded.<br><br><a href="<?php echo "$ip"; echo $_POST['dir']; echo $_POST['name']; echo("."); echo "$ext"; ?>" class="maintext">Click here to view/download it.</a></span>
<?php
}
}
}
?>