943,097 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1427
  • PHP RSS
Apr 24th, 2008
0

uploading iamges to server

Expand Post »
hi i have a simple form where users can upload only images ,i am storing the path to myql and actucal image to a folder on the remote server but when i submit the form iget the image path in my database but not the image in the folder the below code is simple example to my real project i hope i can find hel
the image folder is on the remote server and after uploding the image i need to display it on my site
all this process is working fine on localhost but when i put the page on the main server it does not work security wise i need to make changes if this example works can u plz tell what should i do
php Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. //This is the directory where images will be saved
  4. $target = "http://www.kamila.se/images/";
  5. $target = $target . basename( $_FILES['photo']['name']);
  6.  
  7. //This gets all the other information from the form
  8. $name=$_POST['name'];
  9. $email=$_POST['email'];
  10. $phone=$_POST['phone'];
  11. $pic=($_FILES['photo']['name']);
  12.  
  13. include "databaseconn";
  14.  
  15. //Writes the information to the database
  16. mysql_query("INSERT INTO `employees` VALUES ('$name', '$email', '$phone', '$pic')") ;
  17.  
  18. //Writes the photo to the server
  19. if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
  20. {
  21.  
  22. //Tells you if its all ok
  23. echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
  24. }
  25. else {
  26.  
  27. //Gives and error if its not
  28. echo "Sorry, there was a problem uploading your file.";
  29. }
  30. ?>
  31. <form enctype="multipart/form-data" action="upl.php" method="POST">
  32. Name: <input type="text" name="name"><br>
  33. E-mail: <input type="text" name = "email"><br>
  34. Phone: <input type="text" name = "phone"><br>
  35. Photo: <input type="file" name="photo"><br>
  36. <input type="submit" value="Add">
  37. </form>
Last edited by peter_budo; Apr 26th, 2008 at 8:19 am. Reason: Please use [code] tag for multiple lines and [icode] for single line only
Reputation Points: 10
Solved Threads: 0
Newbie Poster
prethum is offline Offline
14 posts
since Apr 2008
Apr 24th, 2008
0

Re: uploading iamges to server

you can't upload to a remote server unless you use ftp. the way you have it set up is for uploading locally to a local directory. i have never been able to upload to a remote server like that.
Last edited by kkeith29; Apr 24th, 2008 at 11:57 pm.
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Apr 25th, 2008
0

Re: uploading iamges to server

can u plesse guide me how to do i dont matter if its on remote server or loacl server as long as users can upoad there images to the disk(with security in mind) and then i should be able to display these images on my web page,may u plz tell me if its ok to have the image folder on your server
thanking you
jsoeph
Reputation Points: 10
Solved Threads: 0
Newbie Poster
prethum is offline Offline
14 posts
since Apr 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: session not keeping user logged in
Next Thread in PHP Forum Timeline: odbc-connect error--urgent





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC