View Full Version : ftp upload problem
mid-ori
June 18th, 2004, 10:52 AM
hi all.
I'm having problems with a php ftp uploader can somebody look at my script and help me find out why it won't work;
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<form action="myupload.php" method=post enctype="multipart/form-data">
submit this file: <input type=file name="userfile"><br>
<input type=submit><br>
</form>
</body>
</html>
<?
// In PHP earlier then 4.1.0, $HTTP_POST_FILES should be used instead of $_FILES.
if(!empty($_FILES["userfile"])) {
$uploaddir = "/ftp/" // set this to wherever
//copy the file to some permanent location
if (move_uploaded_file($_FILES["userfile"]["tmp_name"], $uploaddir . $_FILES["userfile"]["name"])) {
echo("file uploaded");
} else {
echo ("error!");
}
}
?>
the error i get is: Parse error: parse error in /home/iceni/public_html/myupload.php on line 6
all help welcome
Marble
June 18th, 2004, 11:29 AM
$uploaddir = "/ftp/" should be: $uploaddir = "/ftp/"; notice the ';'
I would advise staying away from short tags. echo also doesn't need ( ) as it's not really a function. Just saves typing. So echo "some message"; is the same as echo ("some message");
T-O
June 18th, 2004, 12:24 PM
$uploaddir = "/ftp/" should be: $uploaddir = "/ftp/"; notice the ';'
I would advise staying away from short tags. echo also doesn't need ( ) as it's not really a function. Just saves typing. So echo "some message"; is the same as echo ("some message");
I think.. The () are good.. Okay you don't need them... But.. You do for writing legal PHP..
mid-ori
June 18th, 2004, 12:25 PM
thanks but know i get a different error
"Warning: Unable to create '/ftp/spacer.gif': No such file or directory in /home/iceni/public_html/myupload.php on line 6 Warning: Unable to move '/tmp/phpKeHlV5' to '/ftp/spacer.gif' in /home/iceni/public_html/myupload.php on line 6 error!"
Marble
June 18th, 2004, 12:27 PM
I think.. The () are good.. Okay you don't need them... But.. You do for writing legal PHP..
No need for them It's stated on php.net site:
"echo() is not actually a function (it is a language construct) so you are not required to use parentheses with it. In fact, if you want to pass more than one parameter to echo, you must not enclose the parameters within parentheses."
Not a big deal, but sure saves a lot of typing when you have hundreds of lines of echos, plus it looks a lot cleaner, imo. Same goes for print, include, include_once, requre, require_once, etc...
Marble
June 18th, 2004, 12:29 PM
thanks but know i get a different error
"Warning: Unable to create '/ftp/spacer.gif': No such file or directory in /home/iceni/public_html/myupload.php on line 6 Warning: Unable to move '/tmp/phpKeHlV5' to '/ftp/spacer.gif' in /home/iceni/public_html/myupload.php on line 6 error!"
Is the directory writable?
mid-ori
June 18th, 2004, 12:30 PM
how do i check that out?
T-O
June 18th, 2004, 12:32 PM
Your doing something wrong... This would only work if the file already exsits on the server.. and you want to update it.
Marble
June 18th, 2004, 12:33 PM
In order for you to write to a directory from the www, you need to make it world readable and writable, and executable is a given. I am assuming you are on a linux server? if so you chmod it to 777. OPen your ftp program and right click on the folder and see if there is an option to chmod it to 777. If you can shell in you can just type:
# chmod 777 folderName
mid-ori
June 18th, 2004, 12:35 PM
yeah, but what i want to do is upload files. view it at http://www.iceni.tv/upload.htm
Marble
June 18th, 2004, 12:37 PM
yeah, but what i want to do is upload files. view it at http://www.iceni.tv/upload.htm
But in order for those files to be "written" to that directory, the directory has to be writable. ;)
mid-ori
June 18th, 2004, 12:38 PM
yeah i've changed the ftp directory chomd to 777, but i'm getting the same error
Marble
June 18th, 2004, 12:47 PM
Try using an absolute path for the dir:
"/home/iceni/public_html/ftp/"
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.