i have a script which works as i were using it in localhost(wampserver),for uploading photo in a directory then the file path to the database.
My problem is that now i`m trying to use the script in the website server where i uploaded my site files,and its giving me the errors as below:
Warning: move_uploaded_file(ftp://........../www/photo/uploads/Biboze.jpg) [function.move-uploaded-file]: failed to open stream: FTP server reports 530 Login authentication failed in /home/kislatco/public_html/photo/upload.php on line 16

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpTPTywF' to 'ftp://......./www/photo/uploads/Biboze.jpg' in /home/kislatco/public_html/photo/upload.php on line 16

The directory i were using in wampserver(localhost) is
$uploadDir = 'c:/wamp/www/photo/uploads/';
And in the webserver which is giving me errors is

ftp://......../www/photo/uploads/
So i dont know what is Wrong?any Help will be apprecited.

Recommended Answers

All 10 Replies

have you authenticated yourself before using ftp?

"failed to open stream: FTP server reports 530 Login authentication failed"

Do you mean login in ftp?

Why are you trying to use FTP with move_uploaded_file() ?
Are you trying to place the file on a server that is different then the one you are uploading too?

check my code below and tell where i`m getting wrong:

<?php

$uploadDir = 'ftp://....../www/photo/uploads/';

if(isset($_POST['upload']))
{
	
	$fileName = $_FILES['userfile']['name'];
	$tmpName = $_FILES['userfile']['tmp_name'];
	$fileSize = $_FILES['userfile']['size'];
	$fileType = $_FILES['userfile']['type'];
     
;
	$filePath = $uploadDir . $fileName;

	$result = move_uploaded_file($tmpName, $filePath);
	if (!$result)
	{
	//echo "Error uploading file";
	$filePath="ftp://......./www/photo/uploads/no_images.jpeg";
	}
		
	if(!get_magic_quotes_gpc())
	{
	$fileName = addslashes($fileName);
	$filePath = addslashes($filePath);
	$fileType = addslashes($fileType);
	} 
	
	
	$dbcnx=@mysql_connect('localhost','****','******');
 if(!$dbcnx){
 exit('<p>unable to connect to the database'.
      ' this time try again later.</p>');
	  }
	  
if (!@mysql_select_db('register')){
	   exit('<p>unable to locate the REGISTER DATABASE'.
	   'AT THIS TIME');
	   }
	
	

	$query = "update picha set path='$filePath',filetype='$fileType',filename='$fileName',date=CURDATE() where user='peacemaker'";//change query according to you
	
	mysql_query($query) or die('Error, query failed');
	$path=$filePath;
	echo "<br>File $fileName uploaded<br>";
	include"index.php";

	
	}
?>

in localhost i used this directory and it was working

<?php
$uploadDir = 'c:/wamp/www/photo/uploads/';
?>

But what are you using FTP for?

if you're on windows: $uploadDir = 'c:/wamp/www/photo/uploads/'; If you're on a windows server still, you should have a similiar path to the directory you want to upload the image too.

if you're on a linux server now, you path with be something like: $uploadDir = '/home/user/public_html/photo/uploads/'; You dont need to use FTP at all. Just make sure the directory you want to upload the image to, exists and is writable.

i changed the directory to

<?php
$uploadDir ='/public_html/photo/uploads/';
?>

And now i`m having the following error,i dont know may be the function move isn`t working


Warning: move_uploaded_file() [function.move-uploaded-file]: open_basedir restriction in effect. File(/public_html/photo/uploads/Naam012.jpg) is not within the allowed path(s): (/home/kislatco:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp) in /home/kislatco/public_html/photo/upload.php on line 16

/home/kislatco/public_html/photo/uploads/

make sure the uploads directory is writable.

when you say writable what do u mean,bcoz i`m new in this.
Sorry if i`m asking a lot.

make sure it has write permissions. is you do something like ls -al, it should have a "w" next to your user group.

in FileZilla for example (ftp program) if you log into your site and right click on any folder or file and choose "File Attributes" it will show you the READ/WRITE/EXECUTE permissions for owner, group and public. This is the same as chmod from the command line on the server. Usually i see mention to try 755 first and then move to 777 if it still wont save the image to the folder. But, do not chmod EVERYTHING to 777

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.