Link to home
Start Free TrialLog in
Avatar of setfocus
setfocus

asked on

PHP move_uploaded_file

Good-day,

I am trying to use move_uploaded_file to upload a file to a server; but for some reason, it's not working... I think I'm missing something simple...

See code attached;

Thanks for your time.
<?php
$my_uploaded_file = "C:\\xampp\\htdocs\\uploads\\my.txt";
$my_local_file = "C:\\my.txt";
 
move_uploaded_file($my_local_file, $my_uploaded_file );
?>

Open in new window

Avatar of Member_2_4694817
Member_2_4694817

Did you check wih is_uloaded_file($my_uploaded_file) ?

Probably the webserver process is not allowed to write to the roo direcory of C:
I think that the function takes arguments
as the paths of the file placed where the web server is

so you cannot enter c:\\my.txt
moreover function move uploaded file
refers to UPLOADED file, so it has to be on the server

www.php.net:
bool move_uploaded_file ( string $filename , string $destination )

This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by destination .

This sort of check is especially important if there is any chance that anything done with uploaded files could reveal their contents to the user, or even to other users on the same system.
Avatar of setfocus

ASKER

Thanks for your comments; how do I upload the file c:\\my.txt to a server using PHP without using HTTP Post?

(this is for a component in joomla 1.5.. so maybe there's an upload function there?)
ASKER CERTIFIED SOLUTION
Avatar of setfocus
setfocus

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
move_uploaded_file() expects to be working with an uploaded file.  If the names you posted up there are the real names, then I wonder if it is not an uploaded file - ie: Has it already been stored on the server? - it does not look like it has one of those temporary names.

If that is the case, just copy the file from C:\\xampp\\htdocs\\uploads\\my.txt to C:\\my.txt

Best, ~Ray
Glad you got it working.  Best regards, ~Ray