|
-
Apr 24th, 2003, 10:11 AM
#1
Thread Starter
Addicted Member
PHP File Upload
Ok, I can manage to throw around a file thats already on a web server with PHP, but how do I get the program to that location on the webserver? Theres gotta be some php code to do that, right?
-
Apr 24th, 2003, 02:51 PM
#2
Thread Starter
Addicted Member
found it in the documentation, for anybody who needs to reference this, it worked fine for me.
http://www.php.net/manual/en/features.file-upload.php
heres how the code looked
<?
$uploaddir = "X:\\whateverdir;
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir .".txt"))
{
print "File is valid, and was successfully uploaded!<br><br>";
}
else
{
print "Possible file upload attack! Here's some debugging info:<br><br>print_r($_FILES)";
}
-
Apr 24th, 2003, 04:22 PM
#3
Frenzied Member
how can you throw around a file on the webserver if it is already there in php?
-
Apr 24th, 2003, 04:53 PM
#4
Stuck in the 80s
Originally posted by phpman
how can you throw around a file on the webserver if it is already there in php?
What? You do realize that you're not making much sense these days...?
-
Apr 24th, 2003, 05:10 PM
#5
Frenzied Member
yup, old age 
let me rephrase that
how can you throw around a file on the webserver if it is already there, by using php?
-
Apr 24th, 2003, 05:17 PM
#6
Stuck in the 80s
Originally posted by phpman
yup, old age 
let me rephrase that
how can you throw around a file on the webserver if it is already there, by using php?
Haha, you're still not making sense to me. Maybe I don't understand the concept of 'throwing a file around.'
I thought he just meant he could move a file around, but wanted to know how to get the file to the server in the first place.
Color me confused, though.
-
Apr 24th, 2003, 05:26 PM
#7
Frenzied Member
hehe that was my impression.
if the file is already there on the server how can he move it around using php? open it up and save it to another folder than delete the old one?
as far as I know there isn't a function to do that. but I have been blind before
-
Apr 28th, 2003, 04:22 PM
#8
Thread Starter
Addicted Member
Sorry I haven't check this thread in awhile...
basically The Hobo was right on. I know how to copy, move, delete, read from, etc etc, a file thats on my server but getting it to my server to play around with was the issue. Heres some file functions from php.net
http://www.php.net/manual/en/function.copy.php
actually thats just the copy function but all the other functions are listed along the left side. I love the way php.net list all the functions and handles documentation.
Have fun.
-
Apr 28th, 2003, 05:08 PM
#9
Stuck in the 80s
Originally posted by TheGoldenShogun
actually thats just the copy function but all the other functions are listed along the left side. I love the way php.net list all the functions and handles documentation.
The downloadable .chm is even better
-
Apr 28th, 2003, 07:01 PM
#10
Frenzied Member
Originally posted by TheGoldenShogun
Sorry I haven't check this thread in awhile...
basically The Hobo was right on. I know how to copy, move, delete, read from, etc etc, a file thats on my server but getting it to my server to play around with was the issue. Heres some file functions from php.net
http://www.php.net/manual/en/function.copy.php
actually thats just the copy function but all the other functions are listed along the left side. I love the way php.net list all the functions and handles documentation.
Have fun.
would you please explain to me how you move a file that is already on the server using php?
-
Apr 29th, 2003, 11:39 AM
#11
Stuck in the 80s
Originally posted by phpman
would you please explain to me how you move a file that is already on the server using php?
Look up information on the copy() and unlink() file functions.
-
Apr 29th, 2003, 02:18 PM
#12
Thread Starter
Addicted Member
from my program, heres an example
function copy_main_file()
{
copy("G:\\PROGRAMS\\UPLOADS\\uploaded_file.tmp", "G:\\PROGRAMS\\SYS\\".$date_name.".tmp");
if (file_exists("G:\\PROGRAMS\\SYS\\".$date_name.".tmp"))
{
echo "Backup of the Uploaded file has been successfully saved..<br>";
}
}
-
Apr 29th, 2003, 08:11 PM
#13
Frenzied Member
well duh, I always thought copy was for uploads. just one of those things.
-
Apr 29th, 2003, 08:47 PM
#14
Stuck in the 80s
Originally posted by phpman
well duh, I always thought copy was for uploads. just one of those things.
I think there is a specific function for that, so you're not completely crazy.
-
Apr 29th, 2003, 09:14 PM
#15
Frenzied Member
well yeah, move_uploaded_file() but I don't like that one and always use copy()
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|