How can I Upload this file to my website using php code
C:\file.txt
Printable View
How can I Upload this file to my website using php code
C:\file.txt
check this out http://www.vbforums.com/showthread.p...hreadid=151689
I try That
copy ("C:\file.jpg", "/image");
but it does not work
What is the error ?
it has to be in this form.
exactly, what is the error you are getting?PHP Code:if (!copy(source, destination)) {
print ("failed to copy file...<br>\n");
}
I used this code
<?
if (!copy("C:\t\ttt.gif","./ttt.gif")) {
print ("failed to copy file...<br>\n");
}
?>
Error:
Warning: Unable to open 'C: tt.gif' for reading: No such file or directory in /home/vbzoom/public_html/vb-chat/copy.php on line 3
failed to copy file
<?
if (!copy("C:\t\ttt.gif","./image")) {
print ("failed to copy file...<br>\n");
}
?>
but I am not sure why you don't want to use a form to upload the file which makes it a lot easier. I am really not positive that you can do it this way.
I might be wrong, but try this:
Not the difference between it and yours.Quote:
<?
if (!copy("C:\\ttt.gif","./ttt.gif")) {
print ("failed to copy file...<br>\n");
}
?>
ok you have to use a form. you can't upload form C: like you want.
I just tried it and it doesn't work. probably some security thing. also you might have to have this so it knows what to do.
<form ENCTYPE="multipart/form-data"
I want to upload the same file every time I run this script without use form . I can not do that ??
Thanks
well you could use the form and make the input hard coded.
<input type=file value="C:\t\ttt.gif" name="myfile">
something like that should work. can't see whay you would want to upload a gif once a day.
Thanks
for the paths thing try using
\\t or //t instead of \t
with the \t it might think its a tab
hobo has the idea
don't you think I have tried that. php doesn't know what is going on if it doesn't have the form headers from the form
<form ENCTYPE="multipart/form-data"
if the file is not in the tmp upload directory then it will not upload it. I tried all thoughs that were suggested.
if that is the case then everytime you went to my site I could upload a win.ini form your computer and then delete it and then your computer would not start. very big secrutiy risk here.
well you could use the form and make the input hard coded.
<input type=file value="C:\t\ttt.gif" name="myfile">
something like that should work. can't see whay you would want to upload a gif once a day
I try that but it does not work.
(input type=file) is not accept value
------
There is any way to upload this file using my UserName and Password of my site such as FTP but using PHP CODE ??????
try
<input type=file value="C:\\t\\ttt.gif" name="myfile">
it thinks the \t's are tabs
(input type=file) is not accept any value at all.
then you will have to insert it everytime and do it the old fashion way.
<form>
<input type="file" name="userfile">
</form>
then you can use the copy from above.
questions on your tutorial.
that is a littel misleading. what ever you make the upload_tmp_dir is still a temp directory an dif you don't move it out within a certain time the server deletes it on cleanup.Quote:
FAQ:
Q: I want to specify a different default folder where files should be uploaded instead of the server "temp" folder -
A: Use the "upload_tmp_dir" directive within php.ini - set it to your target folder
also $HTTP_POST_FILES is deprecated and won't be used in future versions of php as of 4.1.2 everybody should be up to that version at least do to some security issues. also in the future versions of php, register_globals will be turn off as recommended by php. so $HTTP_POST_FILES will not work and you have to use $_FILES[] to do the work.
good tutorial otherwise...
Thanks dude. Updated the tutorial with your errata. Lemme know if anything else is wrong... ;)Quote:
Originally posted by scoutt
questions on your tutorial.
that is a littel misleading. what ever you make the upload_tmp_dir is still a temp directory an dif you don't move it out within a certain time the server deletes it on cleanup.
also $HTTP_POST_FILES is deprecated and won't be used in future versions of php as of 4.1.2 everybody should be up to that version at least do to some security issues. also in the future versions of php, register_globals will be turn off as recommended by php. so $HTTP_POST_FILES will not work and you have to use $_FILES[] to do the work.
good tutorial otherwise...
looks good.
lookk here at the very end right before the commentsQuote:
The file will be deleted from the temporary directory at the end of the request if it has not been moved away or renamed.
http://www.php.net/manual/en/features.file-upload.php