August 30th, 2000, 10:09 PM
-
hello,
i tried the foll code for file upload given
in professional php programming, Wrox Pub.
upload.php
----------
<?
print "original file ".$userfile_name;
if (copy($userfile,"C:upload.txt"))
{
echo("<b>file success </b>");
}
else
{
echo ("<b> Error: fail to copy
file..</b>");
}
unlink($userfile);
?>
upload.htm
----------
<html>
<head>
<title>Untitled</title>
</head>
<body>
<form action="upload.php" method=post enctype="multipart/form-data">
Submit this file : <input type=file name="userfile"><br>
<input type=submit><br>
</form>
</body>
</html>
i tried to upload a file c:testBB.txt
the following error occured :
original file BB.txt
Warning: Unable to open 'php27' for reading: No such file or directory in D
hplearnupload.php on line 4
Error: fail to copy file..
Warning: Unlink failed (No such file or directory) in D
hplearnupload.php on line 12
what could be the problem
any help would be much appreciated
thank u
anitha
August 31st, 2000, 03:06 AM
-
Change the <FORM> method to PUT. 
------------------
To alcohol! The cause of, and solution to, all of life's problems. -- Homer Simpson
August 31st, 2000, 03:41 AM
-
I have enever heard of a form method put, but then again there is a lot I haven't heard of! Usually I set a variable for my upload path
like
$upload_path = "C:uploads".$userfile_name;
if (copy($userfile,$upload_path)) {
print "file uploaded";
}
else {
print "error";
}
September 2nd, 2000, 12:53 AM
-
hello homer,
i changed the <form> method to PUT
but i got a similar error..given below
original file
Warning: Unable to open 'C
intuBB.txt' for reading: No such file or directory in D
hplearnupload.php on line 5
Error: fail to copy file..
Warning: Unlink failed (No such file or directory) in D
hplearnupload.php on line 13
please help
thank u
anitha
September 2nd, 2000, 12:54 AM
-
hello homer,
i changed the <form> method to PUT
but i got a similar error..given below
original file
Warning: Unable to open 'C
intuBB.txt' for reading: No such file or directory in D
hplearnupload.php on line 5
Error: fail to copy file..
Warning: Unlink failed (No such file or directory) in D
hplearnupload.php on line 13
please help
thank u
anitha
September 3rd, 2000, 03:55 AM
-
My mistake, you need to mock up your .htaccess and/or httpd.conf for PUT support... anyways, try this out:
<form method="POST" action="upload.php" enctype="multipart/form-data">
<input name="filename" type="file">
<input type="submit">
</form>
and in your upload.php, have this:
<?php
if (copy($filename,$DOCUMENT_ROOT.$filename)) {
echo "Success!";
} else {
echo "Failure.";
?>
And after that, your uploads should work fine.
------------------
To alcohol! The cause of, and solution to, all of life's problems. -- Homer Simpson
[This message has been edited by cka (edited September 03, 2000).]
September 3rd, 2000, 04:32 AM
-
hi homer
i am sorry to say it didn't work again
it gave the same warning.
Warning: Unable to open 'php2' for reading: No such file or directory in D
hplearnupload.php on line 4
Error: fail to copy file..
Warning: Unlink failed (No such file or directory) in D
hplearnupload.php on line 12
what could be the problem?
thank u
anitha
September 3rd, 2000, 04:34 AM
-
hi homer
i am sorry to say it didn't work again
it gave the same warning.
Warning: Unable to open 'php2' for reading: No such file or directory in D
hplearnupload.php on line 4
Error: fail to copy file..
Warning: Unlink failed (No such file or directory) in D
hplearnupload.php on line 12
what could be the problem?
thank u
anitha
September 3rd, 2000, 04:41 AM
-
hi homer
i am sorry to say it didn't work again
it gave the same warning.
Warning: Unable to open 'php2' for reading: No such file or directory in D
hplearnupload.php on line 4
Error: fail to copy file..
Warning: Unlink failed (No such file or directory) in D
hplearnupload.php on line 12
what could be the problem?
thank u
anitha
September 3rd, 2000, 08:24 AM
-
Greetings,
Use stripslashes() commands.
if (copy(stripslashes($userfile),"C:upload.txt"));
