RE: Re: How to store Images by memeber name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Part 1 Select files for upload:

<form name="upload" id="upload" ENCTYPE="multipart/form-data" method="post"
action="part2.php">

  <p><table border='0' width='400' cellspacing='0' cellpadding='0'
align=center>

  <?php for($i=1; $i<=$max_no_img; $i++){ ?>

  <tr><td>File to upload</td><td>

<input type=file name='images[]' class='bginput'></td></tr>

<?php } ?>

</table>  

    <input name="userid" type="hidden" id="userid" value="<? echo $username
?>" />

    <input type="submit" name="upload" value="Upload">

  </p>

</form>  

 

Part 2 the actual upload:

$username = $_POST['userid'];

                $sql = "SELECT * FROM  users  WHERE Email = '" . $username .
"'";

                                $result = mysql_query($sql) or
die(mysql_error());

                                $row = mysql_fetch_assoc($result);

$upload_here = $row['directory'];

 

while(list($key,$value) = each($_FILES[images][name]))

{

 

if(!empty($value)){   // this will check if any blank field is entered

$filename = $value;    // filename stores the value

 

$filename=str_replace(" ","_",$filename);// Add _ inplace of blank space in
file name, you can remove this line

$url_dir = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);

 

 

//$upload_dir = "test/";

$upload_url = $url_dir."/".$upload_here;

 

$file_path = $upload_here."/".$filename;

//echo "<br>dri: ".$file_path."error: ".$_FILES[images][error][0];

//echo $_FILES[images][type][$key];     // uncomment this line if you want
to display the file type

// echo "<br>";   

//echo "<br>".$filename." file path ".$file_path." tmp name:
".$_FILES[images][tmp_name][$key];

$result = move_uploaded_file($_FILES[images][tmp_name][$key], $file_path);
//  upload the file to the server

}

 

I have 2 entries in the database, username (in my case an email address) and
the directory to upload to.

 

There's another part to create the directory, but that was posted already.

 

Chris

 

From: php-objects@xxxxxxxxxxxxxxx [mailto:php-objects@xxxxxxxxxxxxxxx] On
Behalf Of arvindsri123
Sent: Friday, December 19, 2008 6:23 PM
To: php-objects@xxxxxxxxxxxxxxx
Subject:  Re: How to store Images by memeber name

 

Hello, 

Thank you so much, i have got few scripts but all r do seprate part, i
wanted a single script through that i can upload atleast 10 JPG
images, and those images shoud store in DB as well as in new folder
but folder name should be user name.

I am still searching, If someone will help me with the script, i m not
very expert.

Thank you again for a quick and positive reply.

Thanks,
Avi.

--- In php-objects@xxxxxxxxxxxxxxx <mailto:php-objects%40yahoogroups.com> ,
Joe Forsythe <jforsythe@...> wrote:
>
> if (!(file_exists($directory_name))) {
> mkdir($directory_name);
> }
> 
> Or something like that.
> 
> If you're doing a google search on this topic, you'll want to search 
> for "directory", not "folder"
> --
> Joe
> 
> 
> On Dec 19, 2008, at 4:07 PM, arvindsri123 wrote:
> 
> > Hi,
> >
> > I need a help, I have just created a image upload script in php/mysql,
> > right now all the user's/member's images storing in a common folder.
> >
> > I wanted to store every members images in their own folder, Like when
> > i submit the image upload page, ther must be a new folder created by
> > the user name and all the images must be store in his/her folder, I
> > don't want to create folder manually..
> >
> > If there is any confusion please ask me, I will be very thank full to
> > all of you.
> >
> > Thanks,
> > Avi
> >
> >
> > 
> 
> 
> 
> [Non-text portions of this message have been removed]
>

 



[Non-text portions of this message have been removed]


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux