Page 1 of 1

PHP file upload system, need help customizing it

Posted: Tue Feb 26, 2008 12:46 pm
by syar
I am fairly new to PHP scripting and have come across a little problem. I am creating a file upload system so users can upload there owns photo's. I have got the following script but i need help in customizing it to fit my needs

uploader.php

Code: Select all

 <?php
 
// Where the file is going to be placed 
$target_path = "uploads/";
 
/* Add the original filename to our target path.  
Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
$_FILES['uploadedfile']['tmp_name'];  
 
$target_path = "uploads/";
 
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
 
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
    " has been uploaded";
     require_once('generate.php');
} else{
    echo "There was an error uploading the file, please try again!";
}
 
?>
<br /><br />
<a href="photogallery.php">Click Here to View Your Photo</a>
generate.php

Code: Select all

<?php
$target_path = "uploads/";
 
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
 
    $pfile = fopen("userpics.htm","a+");
 
      // If everything is OK -> store user data
   
        fwrite($pfile, "\n<embed src = \"$target_path\" /><p>");
fclose($pfile);
?>
photos.php (where the user sees the uploaded photo)

Code: Select all

<?php
include("userpics.htm");
?>
I need help to define how the image will look. I need to know how i can get the php code to add a CSS style to the photo and if possible for it to use the lightbox javascript action. The lightbox isn't exactly essential as long as i can link to a full size image but it would be nice. Also the CSS script would shrink the photo for the thumbnail. I just need to link to a full size image.

I hope that you can understand this and that you can help me out cos it is really getting on my nerves now. I have tried everything i can think of

Thanks

Re: PHP file upload system, need help customizing it

Posted: Wed Feb 27, 2008 2:47 pm
by syar
bump

please help

Re: PHP file upload system, need help customizing it

Posted: Wed Feb 27, 2008 2:51 pm
by Jade
Using CSS to make the photo smaller doesn't lower its file size. I would suggest that when they upload a picture you auto-generate a photo for the thumbnail. Otherwise you could have huge pics in your thumbnails.

Re: PHP file upload system, need help customizing it

Posted: Wed Feb 27, 2008 3:08 pm
by syar
I wasn't using the CSS code to make it smaller but i guess i could use PHP to generate a thumbnail for me. How would i do that?

I was using the CSS to mainly add a style to the thumbnail, like adding a border etc. Can I still do this within PHP and make it auto generate the image with the CSS embedded into the tag of the image?