View Full Version : PHP Question
GoldenEagle
09-07-2004, 06:58 PM
I am creating a upload file script and I get the following error:
Warning: copy(/usr/local/apache_1.3.23/00856000.006): failed to open stream: No such file or directory in c:\websites\thecfl.net\upload.php on line 4
Now, I know the problem has to do with Apache. I am not the system admin. Is there any way I can edit the directory myself?
VPI97
09-07-2004, 07:07 PM
Are you just trying to create a subdirectory?
GoldenEagle
09-07-2004, 07:12 PM
Can I do that? Here is what I am thinking: Apache establishes where the file(s) go. The Apache that does that is on the admin's computer. Am I right? If I am, is there a way to get around it?
VPI97
09-07-2004, 07:25 PM
I would think that your code would specify where the files go. Try this:
//Check to see if subdirectory exists
if (file_exists($dirname) || is_dir($dirname)) {
//Nothing
} else {
//Create subdirectory
mkdir($dirname);
}
//Check to see if file exists
if (file_exists("$dirname/$filename")) {
//Delete existing file
unlink ("$dirname/$filename");
}
//Upload file
upload($file, "$dirname/$filename");
Where $dirname = a subdirectory of your choosing, $filename = what to save the file as, and $file = Local path to file
GoldenEagle
09-07-2004, 07:43 PM
Warning: mkdir(): File exists in c:\websites\thecfl.net\upload.php on line 7
Warning: unlink(/): Permission denied in c:\websites\thecfl.net\upload.php on line 12
Fatal error: Call to undefined function: upload() in c:\websites\thecfl.net\upload.php on line 15
That is the new errors that I get.
php
//Check to see if subdirectory exists
if (file_exists($dirname) || is_dir($dirname)) {
//Nothing
} else {
//Create subdirectory
mkdir($dirname);
}
//Check to see if file exists
if (file_exists("$dirname/$filename")) {
//Delete existing file
unlink ("$dirname/$filename");
}
//Upload file
upload($file, "$dirname/$filename");
?>
<html>
<head>
<title>Continential Football League</title>
</head>
<body>
<h3>File upload succeeded...</h3>
</body>
</html>
VPI97
09-07-2004, 08:05 PM
Warning: mkdir(): File exists in c:\websites\thecfl.net\upload.php on line 7
Warning: unlink(/): Permission denied in c:\websites\thecfl.net\upload.php on line 12Doesn't look like you populated the variables
Fatal error: Call to undefined function: upload() in c:\websites\thecfl.net\upload.php on line 15Sorry, I forgot upload() was an inline function...include this function in your code
function upload($src, $dest) {
if(!($fp = fopen($src,"r"))) die("Could not open src");
if(!($fp2 = fopen($dest,"w"))) die("Could not open dest");
while($contents = fread($fp, 4096)) {
fwrite($fp2, $contents, strlen($contents));
}
fclose($fp);
fclose($fp2);
}
GoldenEagle
09-07-2004, 08:19 PM
How can I populate those varaibles when I do not have access to the website folder?
VPI97
09-07-2004, 08:30 PM
Those are things you decide. If someone is uploading a file named 'picture.jpg' to a subdirectory called 'images' you would specify (through code) that $dirname = "images"; $filename = "picture.jpg" and $file would be "C:\My Pictures\picture.jpg" (or whatever)
vBulletin v3.6.0, Copyright ©2000-2026, Jelsoft Enterprises Ltd.