Jump to content

how to upload file using php


new_php85

Recommended Posts

thank you... yes i got it but how come if i need to view uploaded file.because as i know the uploaded files are keep at one folder

 

for example:

 

this is information that i need to save


<?php 
$query = "INSERT INTO pe(staff_id, date_pe, odometer, mileage, receipt, shell, cash, tp_pe) 
              VALUES('$staff_id','$date_pe','$odometer','$mileage','$receipt','$shell','$cash','$tp_pe')"; 
    mysql_query($query) or die('Query failed. ' . mysql_error()); 
?> 

<form name="pe" action='pe.php' method = "post" onSubmit="return validateForm(this,arrFormValidation);"> 
<table width="679" align="center"> 
    <tr>  
        <td height="20" colspan="2" class="tajukkecil"><b>Petrol Expense</b></td>      
    </tr> 
     
    <tr> 
        <td width="119">Date</td> 
           <td width="413">: <input class="special" type="text" name = "date_pe" maxlength = "10" size = "16"><a href="javascript:ShowCalendar('document.pe.date_pe',1900,2030,'dd-mm-yyyy');"><img src="pic/ew_calendar.gif"></a> 
                          <input class="special" type = "hidden" name = "staff_id"  value = "<?php echo $_SESSION['staff_id']?>" Readonly></td>         
    </tr> 
     
    <tr> 
        <td width="119">Odometer</td> 
           <td width="413">: <input class="special" name = "odometer" maxlength = "7" size = "16"></td>         
    </tr> 
     
    <tr> 
        <td width="119">Mileage</td> 
           <td width="413">: <input class="special" name = "mileage" maxlength = "200" size = "46"></td>         
    </tr> 
     
    <tr> 
        <td width="119">Official Receipt No.</td> 
           <td width="413">: <input class="special" name = "receipt" maxlength = "200" size = "16"> 
Choose a file to upload: <input name="uploadedfile" type="file"> 
<input type="submit" value="Upload File"></td>         
    </tr> 
     
    <tr> 
        <td width="119">By Shell Card</td> 
           <td width="413">: RM <input class="special" name = "shell" maxlength = "200" size = "10"> 
                         By Cash : RM <input class="special" name = "cash" maxlength = "200" size = "10"></td>         
    </tr> 
     
    <tr>  
        <td>Toll/Parking</td> 
        <td>: RM <input class="special" type = "float" name = "tp_pe" maxlength = "10" size = "10" value = ""></td>                                       
    </tr> 
     
    <tr>  
        <td> </td> 
        <td align="left"><input class="button" type = "button" name = "bttnList" value = "List Petrol Expenses" onClick="listPe()"> 
                         <input class="button" type = "submit" name = "bttnAdd" value = "Add"> 
                         <input class="button" type = "reset" name = "bttnCancel" value = "Reset"></td> 
    </tr> 
</table> 
</form>

 

and then this is for view

 

<?php 
              $y=1; 
              while($row = mysql_fetch_assoc($result)) 
              { 
              ?> 
          <tr>  
            <td><div align="center"><?php echo $y;?></div></td> 
            <td><?php echo $row['date_pe']?></td> 
            <td><div align="left"><?php echo $row['odometer']?></div></td> 
            <td><div align="left"><?php echo $row['mileage']?></div></td> 
            <td><div align="left"><?php echo $row['receipt']?></div></td> 
            <td width="22"><div align="left">RM</div></td> 
            <td width="68"><div align="right"><?php echo round($row['shell'],2)?></div></td> 
            <td width="21"><div align="left">RM</div></td> 
            <td width="32"><div align="right"><?php echo round($row['cash'],2)?></div></td> 
            <td width="23"><div align="left">RM</div></td> 
            <td width="65"><div align="right"><?php echo round($row['tp_pe'],2)?></div></td> 
            <td width="23"><div align="left">RM</div></td> 
            <td width="65"><div align="right"><?php echo round($row['ammount_pe'],2)?></div></td> 
            <td><div align="center"><a href="editPe.php?pe_id=<?php echo $row['pe_id']?>">Edit</a></div></td> 
             <td><div align="center"><a href="deletePe.php?pe_id=<?php echo $row['pe_id']?>">Delete</a></div></td> 
          </tr> 
          <?php  
              $y++; 
              }  
              ?> 

the how come uploaded file can view??/

 

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.