1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

litle help with image uploading

Discussion in 'PHP' started by Kyriakos, Jun 12, 2009.

  1. #1
    hi,

    i have this PHP code:
    <?php
    $uploadsNeeded = 5;
    for($i = 0; $i < $uploadsNeeded; $i++){
    $file_name = $_FILES['uploadFile'. $i]['name'];
    // strip file_name of slashes
    $file_name = stripslashes($file_name);
    $file_name = str_replace("'","",$file_name);
    $copy = copy($_FILES['uploadFile'. $i]['tmp_name'],$file_name);
     // prompt if successfully copied
     if($copy){
     echo "<span class=\"style1\"><b>".$file_name."</b> uploaded sucessfully!</span><br><br><br>";
     }else{
     echo "";
     }
    }
    ?>
    PHP:
    and i want to set the upload folder to "/upload/" because the images are uploading to the root folder.

    can anybody give a litle help?
     
    Kyriakos, Jun 12, 2009 IP
  2. emed

    emed Peon

    Messages:
    70
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #2
    just modify this line:
    $copy = copy($_FILES['uploadFile'. $i]['tmp_name'],[B]"./upload/".[/B]$file_name);
    Code (markup):
     
    emed, Jun 12, 2009 IP
  3. Dennis M.

    Dennis M. Active Member

    Messages:
    119
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #3
    First, you should probably chmod your root folder to 0755 so you can't upload files there as it's a huge security risk.

    Now chmod upload to 0777 and this your copy(); line to this:
    $copy = copy($_FILES['uploadFile'. $i]['tmp_name'],'uploads/'.$file_name);
    PHP:
    Regards,
    Dennis M.

    NOTE: Repost XD was reading the thread, got up, came back and answered sorry :p
     
    Dennis M., Jun 12, 2009 IP