| | |
uploading iamges to server
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Apr 2008
Posts: 14
Reputation:
Solved Threads: 0
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
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)
<?php //This is the directory where images will be saved $target = "http://www.kamila.se/images/"; $target = $target . basename( $_FILES['photo']['name']); //This gets all the other information from the form $name=$_POST['name']; $email=$_POST['email']; $phone=$_POST['phone']; $pic=($_FILES['photo']['name']); include "databaseconn"; //Writes the information to the database mysql_query("INSERT INTO `employees` VALUES ('$name', '$email', '$phone', '$pic')") ; //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?> <form enctype="multipart/form-data" action="upl.php" method="POST"> Name: <input type="text" name="name"><br> E-mail: <input type="text" name = "email"><br> Phone: <input type="text" name = "phone"><br> Photo: <input type="file" name="photo"><br> <input type="submit" value="Add"> </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
•
•
Join Date: Apr 2008
Posts: 14
Reputation:
Solved Threads: 0
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
thanking you
jsoeph
![]() |
Other Threads in the PHP Forum
- Previous Thread: session not keeping user logged in
- Next Thread: odbc-connect error--urgent
| Thread Tools | Search this Thread |
apache api array basic broken cache cakephp class cms code computing confirm countingeverycharactersfromastring crack cron curl customizableitems database date decode delete dynamic echo email error fcc file filter folder form forum freelancing function functions gc_maxlifetime header headmethod howtowriteathesis href htaccess html iframe image include incode integration ip javascript joomla limit link login malfunction match memmory memory menu method mod_rewrite multiple mysql navigation neutrality oop parsing paypal pdf php phpmysql protocol query question random recursiveloop root script search select server sessions sms snippet soap source space sql strip_tags support! system table template thesishelp trouble tutorial upload url variable web window.onbeforeunload=closeme; youtube






