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 402,682 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,340 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: 448 | Replies: 2
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  

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

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

 

Thread Tools Display Modes

Other Threads in the PHP Forum

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