-
Hi, I have this file upload skript here from Kevin's tutorial.
But I don't know in which directory I have to upload the files to. All I know is, that my server is a unix server and on my server it looks like this here : /home/mydomain/www/mydirectory
And this is the script :
<?PHP
include ("common.php");
if ($submit) {
if ("image/pjpeg" == $uploadedfile_type or "image/gif" == $uploadedfile_type) {
if ("image/pjpeg" == $uploadedfile_type )
$extension = ".jpg";
else
$extension = ".gif";
$filename = "/home/myserver/www/mydirectory" . time() . $REMOTE_HOST . $extension;
if (copy($uploadedfile, $filename)) {
echo(" Ok, file was uploaded");
} else {
echo(" An error has occured");
}
}
else {
error ("Please use .gif ore .jpg");
}
}
else {
?>
<html>
<head>
<title>Untitled Document</title>
</head>
<body bgcolor="#FFFFFF">
<form method="post" action="<?=$PHP_SELF?>" Enctype="multipart/form-data">
<input type="File" name="uploadedfile">
<input type="submit" name="submit" value="Submit">
<input type="hidden" name="MAX_FILE_SIZE value="1024">
</form>
</body>
</html>
<?PHP
}
?>
Using this directory for the file upload ( I'm sure this is wrong ) I get the error message :
Unable to create '/home/mydomain/www/mydirectory985121283.gif': Permission denied
What could be wrong here. I got this "permission denied" problem in some other cases to, do I have to change some settings on my server or is there any problem with the skript ( oh sorry, it is 'script', I learned it in this forum some days ago. )
Thanks for your help
-
Make sure the file
mydirectory exists and has write permissions usually 777
Now for your script this line here
PHP Code:
$filename = "/home/myserver/www/mydirectory" . time() . $REMOTE_HOST . $extension;
You left oiut the slash after mydirectory and this line should read
PHP Code:
$filename = "/home/myserver/www/mydirectory/" . time() . $REMOTE_HOST . $extension;
-
What exactly do you mean with :
"write permissions usually 777 "
I have never heard about it?
-
The folder where the images will go needs to have permissions for the web server to write files into it. Since the webserver normally runs as nobody. You will most likely need to set this folder's permission to 777.
Telnet instructions
1) Login
2) type this at the prompt
chmod 777 /home/myserver/www/mydirectory/
FTP instructions
1) Login using cute or ws_ftp or whatever you use.
2) right click on the directory in question and look for permissions in one of the menus or the right click menu and set it to 777
-
..wait a second...I will have a try
-
I have some problems with the speed of sitepointforums today.
I did something called "chmod" and changed it to read,write and execute and now it is working fine.
So now I will go on and store the location of the file in my database, that will be easy. But how can I than get this file displayed. Let's say I have a SQL Query "Select name,filelocation FROM...." then I get the filelocation, which will be something like "myfolder/12345.gif". But how can I display this file than ?
-
Basic html my friend
PHP Code:
$display_path = "http://mydomain.com/";
while(.... get data) {
printf('<img src="%s">', $dislpay_path.$row["imgaename"]);
}
-
Yes I knew it, I just wanted to test you :-)
Thanks a lot, Alex
-
Foolish smorb ;)
Don't you know my cat knows everything!
-
Ok.... gezz! :eek2: this board is cool, i was testing this form....
How do you do this... DHTML? (the size , bold and stuff)
Ok, to the topic.... what was it?.... oh!, ok.
What if i want the user to upload a file .jpg or .gif only, but with the original filename?
-
Actually the bold, italics, etc. are JavaScript and come standard with vBulletin v2.