I want to upload 20 images for each member and store the filepaths in a databse alongwith their other details. I have tried out some image upload scripts but I am not able to insert the path in the table.Can anyone pls help.
@phpnoviceJan 22.2005 — #[i]Originally posted by ashokvas [/i]
[B]I am not able to insert the path in the table.Can anyone pls help. [/B][/QUOTE] Are you talking about the original path that the file had on the visitor's machine? ...or, the path under which you save the file on the server?
@phpnoviceJan 23.2005 — #Well, the following is an example I got from the [url=http://us2.php.net/get/php_manual_chm.zip/from/a/mirror]us2.php extended php manual[/url].
(Sorry, I couldn't get this site to not break the IF statement in the wrong place.) [code=php]<?php // In PHP earlier then 4.1.0, $HTTP_POST_FILES should be used instead of // $_FILES. In PHP earlier then 4.0.3, use copy() and is_uploaded_file() // instead of move_uploaded_file
@ashokvasauthorJan 23.2005 — #Thanks.But I am having problem inserting the filename in the database.Also what to do for
1)I want to name the file with a new name,using a fixed name,like 'photo1' or 'photo2'....
2)If I dont like the photo uploaded to 'photo1' location earlier,then I should be able to upload another photo to that location and overwrite the earlier image file.
@phpnoviceJan 23.2005 — #[i]Originally posted by ashokvas [/i]
[B]I am having problem inserting the filename in the database.[/B][/QUOTE] Show the code you're attempting to use to insert the file name into the database.
[code=php]<?php include ("access_user_class.php");
$page_protect = new Access_user; // $page_protect->login_page = "login.php"; // change this only if your login is on another page $page_protect->access_page(); // only set this this method to protect your page
if (isset($_GET['action']) && $_GET['action'] = "log_out") { $page_protect->log_out(); // the method to log off } include ("upload_class.php"); //classes is the map where the class file is stored (one above the root) include("mysql_connectinfo.inc"); $max_size = 1024*100; // the max. size for uploading echo "Welcome ".$_SESSION['user']." !"; echo "Welcome ".$_SESSION['pw']." !"; $my_upload = new file_upload;
$my_upload->upload_dir = "images/"; // "files" is the folder for the uploaded files (you have to create this folder) $my_upload->extensions = array(".png",".gif",".jpg", ".zip"); // specify the allowed extensions here // $my_upload->extensions = "de"; // use this to switch the messages into an other language (translate first!!!) $my_upload->max_length_filename = 100; // change this value to fit your field length in your database (standard 100)
if(isset($Submit)) { $my_upload->the_temp_file = $_FILES['upload']['tmp_name']; $my_upload->the_file = $_FILES['upload']['name']; $my_upload->http_error = $_FILES['upload']['error']; $my_upload->replace = "y"; // because only a checked checkboxes is true $my_upload->rename_file = "true"; $my_upload->do_filename_check = (isset($_POST['check'])) ? $_POST['check'] : "n"; // use this boolean to check for a valid filename $my_upload->upload(); // use the following if clause to do something if the upload is true if ($my_upload->upload()) { $src_filename="images/".$this->file_copy ; $sql = "UPDATE users SET foto1 = '$src_filename' WHERE pw = $_SESSION['pw'] AND login=$_SESSION['user']";