Jump to content

move_uploaded_file - Please HELP me

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
EanVee

EanVee

    Newbie

  • Members
  • Pip
  • 1 posts
Storing multiple Images In MySQL is a challenge, but moving them seems impossible (all the various tutorials I've seen/read are for single images). This whole Blob thing has got me confused.
Please help me with the move_uploaded_file function.

<div style="border: 2px solid 
rgb(153, 153, 153); width: 545px; margin: 1px; padding: 0px 20px; 
background-color: rgb(216, 0, 1);">
                                            <div style="display: block;"
 id="country1" class="tabcontent">
                                                   
                                                    
                                                <fieldset id="UploadPan"
 style="width: auto; height: auto; border: 1px solid rgb(255, 255, 255);
 margin: 0px; padding: 10px;">
                                                    <legend 
style="font-weight: bold; color: rgb(255, 255, 255); padding: 2px;">Upload
 your Photos</legend>
                                                    <table>
                                                        <tbody><tr>
                                                            <td 
style="width: 83px;" valign="top">
                                                                Photo 1 :</td>
                                              <td><input 
name="fileUpload1" id="fileUpload1" style="width: 350px;" type="file" />
                                                  <br />
                                                  <span
 id="RegularExpressionValidator3" style="color: White; display: none;">Only
                                                    .jpg File Format</span> </td>
                                            </tr>
                                            <tr>
                                              <td 
style="width: 83px;" valign="top"> Photo 2 :</td>
                                              <td><input 
name="fileUpload2" id="fileUpload2" style="width: 350px;" type="file" />
                                                  <br />
                                                  <span 
id="RegularExpressionValidator2" style="color: White; visibility: 
hidden;">Only .jpg File Format</span> </td>
                                            </tr>
                                          </tbody>
                                          </table>
                                    </fieldset>
                                        <br />
                                        <br />
                                        <fieldset 
id="BarCodePan" style="width: auto; height: auto; border: 1px solid 
rgb(255, 255, 255); margin: 0px; padding: 10px;">
                                        <legend 
style="font-weight: bold; color: rgb(255, 255, 255);">Upload your 
                                          Barcode</legend>
                                          <table border="0">
                                          <tbody>
                                            <tr>
                                              <td 
colspan="2"> HOW YOU 
                                                GET IT <br />
                                                If 
                                                you're not already a member, sign up with The <a 
href="http://castingfrontier.com/" class="hype2" target="_blank">Casting
                                                  Frontier </a>now for free.<br />
                                                - After 
                                                logging in, under "Editing Tools," click "Print ID Barcode." <br />
                                                - Right 
                                                click on the barcode and select "Save Image As." Don't rename or change
                                                the file
                                                type - it will save as a .png file, with your ID# as the file name.<br />
                                                - Add 
                                                your barcode by clicking in browse button. </td>
                                              <td 
valign="top"><a 
href="http://castingfrontier.com/" target="_blank" class="hype2"> <img
 src="PHCorders_files/tcf.jpg" alt="" border="0" /></a></td>
                                            </tr>
                                            <tr>
                                              <td 
valign="top" width="100"> Barcode :</td>
                                              <td 
valign="top"><input 
name="fileUpload3" id="fileUpload3" style="width: 350px;" type="file" />
                                                  <br />
                                                  <span 
id="RegularExpressionValidator1" style="color: White; visibility: 
hidden;">Only .png File Format</span> </td>
                                              <td 
style="height: 41px;"></td>
                                            </tr>
                                          </tbody>
                                          </table>
                                        </fieldset>
                                        <br />
                                        <br />
                                        <div style="color: 
Black; font-weight: bold;">
                                          <input 
name="Button1" value="Upload" onclick='return 
script2();WebForm_DoPostBackWithOptions(new 
WebForm_PostBackOptions("Button1", "", true, "", "", false, false))' 
id="Button1" class="btn" style="width: 80px;" type="submit" />
                                          <br />
                                          <br />
                                          <div 
id="divProgress2" style="width: 300pt; display: none;" align="left"> Wait, upload is 
                                            in progress..... <br />
                                            <br />
                                            <script type="text/javascript">
                var bar1= createBar(300,15,'white',1,'black','black',85,7,3,"");
                                                        </script>
                                            <div 
id="_xpbar0" style="visibility: visible; position: relative; overflow: 
hidden; width: 300px; height: 15px; background-color: white; border: 1px
 solid black; font-size: 1px;"><span id="blocks0" style="left: 17px; 
position: absolute; font-size: 1px;"><span style="background-color: 
black; left: 0px; font-size: 1px; position: absolute; width: 15px; 
height: 15px;"></span><span style="background-color: black; left: -16px;
 font-size: 1px; position: absolute; width: 15px; height: 15px;"></span><span
 style="background-color: black; left: -32px; font-size: 1px; position: 
absolute; width: 15px; height: 15px;"></span><span 
style="background-color: black; left: -48px; font-size: 1px; position: 
absolute; width: 15px; height: 15px;"></span><span 
style="background-color: black; left: -64px; font-size: 1px; position: 
absolute; width: 15px; height: 15px;"></span><span 
style="background-color: black; left: -80px; font-size: 1px; position: 
absolute; width: 15px; height: 15px;"></span><span 
style="background-color: black; left: -96px; font-size: 1px; position: 
absolute; width: 15px; height: 15px;"></span></span></div>
                                          </div>
                                          <br />
                                          <span 
id="Upload_Complete"></span> <span 
id="Upload_Failed"></span> </div>
                                    </div>
                                  </div>

Edited by Jaan, 02 April 2010 - 04:41 AM.


#2
webcodez

webcodez

    Programmer

  • Members
  • PipPipPipPip
  • 149 posts
Hmm, what exactly is your question? What you want to get done?

If you just want to upload an image and save it in database:

<?php

if($_POST) {

$filename = $_FILES['uploadfile']['name'];

$path = "uploads/{$filename}"; //example upload path

if(move_uploaded_file($_FILES['uploadfile']['tmp_name'], $path)) {

  echo "File uploaded";
  $store_file = mysql_query("INSERT INTO files(filename, filepath)VALUES('".mysql_real_escape_string($_FILES['uploadfile']['name'])."', '$path')"); //example store query

}else{

  echo "File upload error occured.";

}

}else{

//show upload form
//in example the file input field name = 'uploadfile'

}

?>

   

EDIT: for multiple files just make it a loop like:

foreach($_FILES as $file) {

   //do the same process as above but then replace all $_FILES['uploadfile'] by $file

}