Hi,
copy(source_file,target_file)
Where should be the source file ?
On client?
On server?
An URL on web?
Can we solve this problem?
Hi,
copy(source_file,target_file)
Where should be the source file ?
On client?
On server?
An URL on web?
Can we solve this problem?
I think I got the solution :
Before PHP Version 5.2.9 "the source file" could be placed on local computer or on remote server (on the web) or it could be URL on the web.
The location of the source file doesn't make any difference if the server has the PHP Version older than 5.2.9. There will be no errors while uploading a file from the user's computer to the web server that the script is running on via a form enctyped as multipart/form-data.
But in version 5.2.9 the source file can only be either a URL on the web or a path on remote server (on the web). Copy() function interprets the POSTed file path as a path on remote server on the web.
If the above commitment is incorrect or missing some points please let me know.
Nejat
Last edited by psikolog; 09-02-2009 at 03:27 PM.
Can be either one. For example ...
-OR-PHP Code:copy("C:/Desktop/MyFile.txt", "uploads/");
-OR-PHP Code:copy("../files/MyFile.txt", "uploads/");
For more info, see:PHP Code:copy("/home/user/files/MyFile.txt", "uploads/");
http://php.net/copy
- Josh
psikolog (09-02-2009)
I know what www.php.net declares.
But in version 5.2.9 user can't upload a file to the server via a form.
I tested the code
1. on my local server (on my computer) => it worked.
2. on Yahoo server with version 4.3.11 => it worked.
3. on another server with version 5.2.9 => it did not worked.
Thank you. I will appreciate your comments.
Nejat
Right, like posted before, sounds to me like it's a configuration problem with the server. That happens. I'll google for you and tell you what I come up with.
BTW, see:
http://www.dynamicdrive.com/forums/s...8086&page=2#12
- Josh
Problem is, we don't know WHAT exactly is going on. This code may help you:
... taken directly from:PHP Code:<?php
function file_upload_error_message($error_code) {
switch ($error_code) {
case UPLOAD_ERR_INI_SIZE:
return 'The uploaded file exceeds the upload_max_filesize directive in php.ini';
case UPLOAD_ERR_FORM_SIZE:
return 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form';
case UPLOAD_ERR_PARTIAL:
return 'The uploaded file was only partially uploaded';
case UPLOAD_ERR_NO_FILE:
return 'No file was uploaded';
case UPLOAD_ERR_NO_TMP_DIR:
return 'Missing a temporary folder';
case UPLOAD_ERR_CANT_WRITE:
return 'Failed to write file to disk';
case UPLOAD_ERR_EXTENSION:
return 'File upload stopped by extension';
default:
return 'Unknown upload error';
}
}
$dest = "upload/";
copy($_FILES['file'], $dest);
// Example
if ($_FILES['file']['error'] === UPLOAD_ERR_OK)
// upload ok
else
$error_message = file_upload_error_message($_FILES['file']['error']);
?>
http://us3.php.net/manual/en/feature...oad.errors.php
[that may or may not work. proofread the code]
But point of that code will be, if it's a server problem, you'll either get case 6 or 8.
- Josh
I think I found another possibility:
http://us3.php.net/manual/en/feature...n-pitfalls.php
IF the file is fairly large, there could be a timeout limit -OR- the server MAX_UPLOAD_SIZE is not letting you upload a file that big,
Try uploading a really really tiny file, like a .txt file with nothing in it. If that fails, then this idea should be knocked off the board.
- Josh
All php.ini values are ok, and my filesizes are between 1 kb and 17 kb.
I also used the same file (3 kb) for all my tests.
In fact before posting this issue I did a wide research (took my 3 days), I reached to an explanation but I could not solve it.
Hoping to solve this problem alltogether.
Thank you.
Nejat
The error message is :
Warning: copy(C:\\wamp\\www\\noyaevofis\\images\\block.png) [function.copy]: failed to open stream: No such file or directory in .........
I think the server : "there is no path such 'C:\\wamp\\www\\noyaevofis\\images\\block.png' in my disk." says.
Why don't you guys consolidate this to just one thread.
There is definitely no path like this: C:\\wamp\\www\\noyaevofis\\images\\block.png
Now what could be causing you to have two directory separtors instead of one? I do not know...
Bookmarks