Jump to content

Picture Uploading


Accurax

Recommended Posts

I'm looking to create a systemm where my members can upload pictures to the webserver, and then have them displayed on their respective member pages.

I would like to avoid actually storing the picture itself in the database if at all possible... and would like to simply store the path to the picture.

I'm presuming that i could then call the stored path into an img src= statement and have the picture displayed.... is this correct?

I'm also having a remarkable ammount of agrovation learning exactly how to upload a picture to the webserver ..... the tutorials ive seen are eitehr way too complex... or crap.

All ive managed to learn is that i need to use a form like:

[code]
<form method="post" enctype="multipart/form-data">
<table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
<tr>
<td width="246">
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<input name="userfile" type="file" id="userfile">
</td>
<td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>
</tr>
</table>
</form>[/code]

Which is all well and good.... but how do i actually get the picture to where i want it stored.... and then get the path to that picture stored in the database?
Link to comment
https://forums.phpfreaks.com/topic/29927-picture-uploading/
Share on other sites

Ok, ive managed to get the files uploading successfully with the following script... im not sure hoe secure this is, but ill have to address that once everything works.

[code]
<?php
if ($_REQUEST[completed] == 1) {
      $source = "pictures";
      move_uploaded_file($_FILES['filename']['tmp_name'],
              "../..../..../$source/".$_FILES['filename']['name']);
// Following code to fix line ends
      if (! eregi ('(gif|jpg|pdf)$',$_FILES['filename']['name'])) {
      $fi = file("../.../..../$source/".$_FILES['filename']['name']);
      $fi2 = fopen("../..../..../$source/".$_FILES['filename']['name'],"w");
      foreach ($fi as $lne) {
              $n = rtrim ($lne);
              fputs ($fi2,"$n\n");
              }
      }
//
?>

I just need to figure out how to store the path to this file in my mysql database as the file is uploaded.... and i probably need a method of renaming the file aswell... just an arbitary number would do... any suggestions guys?

Thanks in advance[/code]
Link to comment
https://forums.phpfreaks.com/topic/29927-picture-uploading/#findComment-137513
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.