problem uploading photo in webserver

Reply

Join Date: Mar 2008
Posts: 217
Reputation: mrcniceguy is an unknown quantity at this point 
Solved Threads: 4
mrcniceguy mrcniceguy is offline Offline
Posting Whiz in Training

problem uploading photo in webserver

 
0
  #1
Jan 12th, 2009
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.
Last edited by mrcniceguy; Jan 12th, 2009 at 9:28 pm. Reason: forgot something
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 686
Reputation: sillyboy is on a distinguished road 
Solved Threads: 61
sillyboy's Avatar
sillyboy sillyboy is offline Offline
Practically a Master Poster

Re: problem uploading photo in webserver

 
0
  #2
Jan 13th, 2009
have you authenticated yourself before using ftp?

"failed to open stream: FTP server reports 530 Login authentication failed"
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 217
Reputation: mrcniceguy is an unknown quantity at this point 
Solved Threads: 4
mrcniceguy mrcniceguy is offline Offline
Posting Whiz in Training

Re: problem uploading photo in webserver

 
0
  #3
Jan 13th, 2009
Do you mean login in ftp?
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 148
Reputation: mschroeder is on a distinguished road 
Solved Threads: 25
mschroeder mschroeder is offline Offline
Junior Poster

Re: problem uploading photo in webserver

 
0
  #4
Jan 13th, 2009
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?
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 217
Reputation: mrcniceguy is an unknown quantity at this point 
Solved Threads: 4
mrcniceguy mrcniceguy is offline Offline
Posting Whiz in Training

Re: problem uploading photo in webserver

 
0
  #5
Jan 13th, 2009
check my code below and tell where i`m getting wrong:
  1. <?php
  2.  
  3. $uploadDir = 'ftp://....../www/photo/uploads/';
  4.  
  5. if(isset($_POST['upload']))
  6. {
  7.  
  8. $fileName = $_FILES['userfile']['name'];
  9. $tmpName = $_FILES['userfile']['tmp_name'];
  10. $fileSize = $_FILES['userfile']['size'];
  11. $fileType = $_FILES['userfile']['type'];
  12.  
  13. ;
  14. $filePath = $uploadDir . $fileName;
  15.  
  16. $result = move_uploaded_file($tmpName, $filePath);
  17. if (!$result)
  18. {
  19. //echo "Error uploading file";
  20. $filePath="ftp://......./www/photo/uploads/no_images.jpeg";
  21. }
  22.  
  23. if(!get_magic_quotes_gpc())
  24. {
  25. $fileName = addslashes($fileName);
  26. $filePath = addslashes($filePath);
  27. $fileType = addslashes($fileType);
  28. }
  29.  
  30.  
  31. $dbcnx=@mysql_connect('localhost','****','******');
  32. if(!$dbcnx){
  33. exit('<p>unable to connect to the database'.
  34. ' this time try again later.</p>');
  35. }
  36.  
  37. if (!@mysql_select_db('register')){
  38. exit('<p>unable to locate the REGISTER DATABASE'.
  39. 'AT THIS TIME');
  40. }
  41.  
  42.  
  43.  
  44. $query = "update picha set path='$filePath',filetype='$fileType',filename='$fileName',date=CURDATE() where user='peacemaker'";//change query according to you
  45.  
  46. mysql_query($query) or die('Error, query failed');
  47. $path=$filePath;
  48. echo "<br>File $fileName uploaded<br>";
  49. include"index.php";
  50.  
  51.  
  52. }
  53. ?>

in localhost i used this directory and it was working
  1. <?php
  2. $uploadDir = 'c:/wamp/www/photo/uploads/';
  3. ?>
Last edited by mrcniceguy; Jan 13th, 2009 at 11:56 am. Reason: so.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 148
Reputation: mschroeder is on a distinguished road 
Solved Threads: 25
mschroeder mschroeder is offline Offline
Junior Poster

Re: problem uploading photo in webserver

 
0
  #6
Jan 13th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 217
Reputation: mrcniceguy is an unknown quantity at this point 
Solved Threads: 4
mrcniceguy mrcniceguy is offline Offline
Posting Whiz in Training

Re: problem uploading photo in webserver

 
0
  #7
Jan 13th, 2009
i changed the directory to
  1. <?php
  2. $uploadDir ='/public_html/photo/uploads/';
  3. ?>
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 148
Reputation: mschroeder is on a distinguished road 
Solved Threads: 25
mschroeder mschroeder is offline Offline
Junior Poster

Re: problem uploading photo in webserver

 
0
  #8
Jan 13th, 2009
/home/kislatco/public_html/photo/uploads/

make sure the uploads directory is writable.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 217
Reputation: mrcniceguy is an unknown quantity at this point 
Solved Threads: 4
mrcniceguy mrcniceguy is offline Offline
Posting Whiz in Training

Re: problem uploading photo in webserver

 
0
  #9
Jan 13th, 2009
when you say writable what do u mean,bcoz i`m new in this.
Sorry if i`m asking a lot.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 686
Reputation: sillyboy is on a distinguished road 
Solved Threads: 61
sillyboy's Avatar
sillyboy sillyboy is offline Offline
Practically a Master Poster

Re: problem uploading photo in webserver

 
0
  #10
Jan 13th, 2009
make sure it has write permissions. is you do something like ls -al, it should have a "w" next to your user group.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC