Jump to content

Can somebody help me make my single file upload script into a multiple one?


Stevis2002

Recommended Posts

nothing gets entered into the url field in the database, just NULL..

 

That's because the code you put in does not have or set any value for that field in the database.

 

Someone has suggested twice in this thread that you need to define how you are going to store multiple images and associate them with the correct information in the database. The sample code I posted did associate the multiple files with the id in the database by including the id as part of the file name. If you want something different than that method, you will need to define it and then write the code to accomplish it.

Hi mate,

 

How much would you charge just to finish this script off for me so it uploads multiple images, and stores url&image info in db?

 

I think i will be able to manage to get the info back out ok and disply the image(s)

 

Cheers,

Steve

Link to comment
Share on other sites

nothing gets entered into the url field in the database, just NULL..

 

That's because the code you put in does not have or set any value for that field in the database.

 

Someone has suggested twice in this thread that you need to define how you are going to store multiple images and associate them with the correct information in the database. The sample code I posted did associate the multiple files with the id in the database by including the id as part of the file name. If you want something different than that method, you will need to define it and then write the code to accomplish it.

Hi mate,

 

How much would you charge just to finish this script off for me so it uploads multiple images, and stores url&image info in db?

 

I think i will be able to manage to get the info back out ok and disply the image(s)

 

Cheers,

Steve

 

Aimed at PFMaBiSmAd  BTW lol

Link to comment
Share on other sites

Ok,

 

So now i have altered the way i am dealing with images to try and make it easier for me to get working, but it is not uploading file to server, or file info to db.

I have made the extra db fields, pic1, pic2 etc, but nothing is getting there

 

if(isset($_POST['submit']))  

{  

$customername = $_POST['customername'];  
$imagename = $_POST['imagename'];  
$testimonial = $_POST['testimonial']; 
$sort_order = $_POST['sortorder'];
$town = $_POST['town'];

$uploaddir = 'uploaded_images/';  

$uploadfile = $uploaddir . basename($_FILES['ipic1']['imagename']);  
    

echo($_FILES['ipic1']['type']);  
   
move_uploaded_file($_FILES['ipic1']['tmp_name'], $uploadfile);     

$pic1 = $_FILES['ipic1']['imagename'];  


$uploaddir2 = 'uploaded_images/';  

$uploadfile2 = $uploaddir2 . basename($_FILES['ipic2']['imagename']);  
     

echo($_FILES['ipic2']['type']);  


move_uploaded_file($_FILES['ipic2']['tmp_name'], $uploadfile2);  
   

$pic2 = $_FILES['ipic2']['imagename'];  


$uploaddir3 = 'uploaded_images/';  

$uploadfile3 = $uploaddir3 . basename($_FILES['ipic3']['imagename']);  
   

echo($_FILES['ipic3']['type']);  

  

move_uploaded_file($_FILES['ipic3']['tmp_name'], $uploadfile3);  

  

$pic3 = $_FILES['ipic3']['imagename'];  


$uploaddir4 = 'uploaded_images/';  

$uploadfile4 = $uploaddir4 . basename($_FILES['ipic4']['imagename']);  
  

echo($_FILES['ipic4']['type']);  

   

move_uploaded_file($_FILES['ipic4']['tmp_name'], $uploadfile4);  
   
$pic4 = $_FILES['ipic4']['imagename'];  

$uploaddir5 = 'uploaded_images/';  

$uploadfile5 = $uploaddir5 . basename($_FILES['ipic5']['imagename']);  
  

echo($_FILES['ipic5']['type']);  

   

move_uploaded_file($_FILES['ipic5']['tmp_name'], $uploadfile5);  
   
$pic5 = $_FILES['ipic5']['imagename']; 
   
               $query=sprintf("INSERT INTO testimonials (CustomerName, Town, Testimonial, SortOrder, pic1, pic2, pic3, pic4, pic5)
                  VALUES
                  ('$customername','$town','&testimonial','$sort_order','$pic1','$pic2','$pic3','$pic4','$pic5')",
                  mysql_real_escape_string($_POST['customername']),
                  mysql_real_escape_string($_POST['town']),
                  mysql_real_escape_string($_POST['testimonial']),
                  mysql_real_escape_string($_POST['sort_order']),
			  mysql_real_escape_string($_POST['pic1']),
			  mysql_real_escape_string($_POST['pic2']),
			  mysql_real_escape_string($_POST['pic3']),
			  mysql_real_escape_string($_POST['pic4']),
			  mysql_real_escape_string($_POST['pic5'])
                  );

mysql_query($query) or die('Error, insert query failed, could not connect to database');  



echo "New testimonial added  \n";  


}  

?> 


<form action="" method="post" enctype="multipart/form-data" name="add_test" id="add_test">
  <p> </p>
  <p align="center">
    <label for="customername">Customer Name:</label>
    <input name="customername" type="text" id="customername" maxlength="150" value="<?php echo $_POST['customername']; ?>" />
  </p>
  <p align="center">
    <label for="town">Town/City:   </label>
    <input name="town" type="text" id="town" maxlength="150" value="<?php echo $_POST['town']; ?>" />
  </p>
  <p align="center">
    <label for="testimonial"><u>Testimonial </u></label>
  </p>
  <p align="center">
    <textarea name="testimonial" id="testimonial" cols="60" rows="10"><?php echo $_POST['testimonial']; ?></textarea>
  </p>
  <p align="center">
    <label for="sort_order">Sort Order: </label>
    <input name="sort_order" type="text" id="sort_order" size="10" maxlength="3" value="<?php echo $_POST['sort_order']; ?>" />
  </p>
  <p align="center">  
   <input type="hidden" name="MAX_FILE_SIZE" value="500000" /> 
   <input type="file" name="ipic1" /><br />
   <input type="file" name="ipic2" /><br />
   <input type="file" name="ipic3" /><br />
   <input type="file" name="ipic4" /><br />
   <input type="file" name="ipic5" />
  </p>

  <p align="center">
    <input type="submit" name="submit" id="submit" value="Submit" />
  </p>
  <p> </p>
  <p> </p>
</form> 
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.