User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 374,006 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,853 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 323 | Replies: 2
Reply
Join Date: Apr 2008
Posts: 12
Reputation: prethum is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
prethum prethum is offline Offline
Newbie Poster

uploading iamges to server

  #1  
Apr 24th, 2008
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
  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 7:19 am. Reason: Please use [code] tag for multiple lines and [icode] for single line only
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 522
Reputation: kkeith29 is on a distinguished road 
Rep Power: 3
Solved Threads: 51
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Posting Pro

Re: uploading iamges to server

  #2  
Apr 24th, 2008
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 10:57 pm.
Reply With Quote  
Join Date: Apr 2008
Posts: 12
Reputation: prethum is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
prethum prethum is offline Offline
Newbie Poster

Re: uploading iamges to server

  #3  
Apr 25th, 2008
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
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Other Threads in the PHP Forum

All times are GMT -4. The time now is 10:25 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC