SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    731
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Change Upload Location

    Hi,

    I have a code which uploads an image but I cant seem to work out how to change the upload the location.

    I am looking for an image to be uploaded to www.website.com/userimages/logo.php

    I have tried a few options but I just cant get it upload to a designated location.

    Code:
     else { 
            // Set the direntory for where to upload it, use the member id to hit their folder
            // Upload the file
    	    /*if(isset($_GET['id'])){
    		if (!is_dir('memberFiles/'.$id.'/images/')) { //if memberFiles folder does not exist
     			mkdir('memberFiles/'.$id.'/images/'); //make the folder 
    		}*/
    		if (!is_dir('images/')) { //if memberFiles folder does not exist
     			mkdir('images/'); //make the folder 
    		}
    	        $target_path = 'images/'; //set targetpath
    }
    		//adjust target path to create new file name which include $id and current date and original filename
    		$ref = "-". gmdate('jmyhis') ."-". basename( $_FILES['uploadLogo']['name']);
    		$target_path .= $ref;
    		$filename = basename($_FILES['uploadLogo']['name']); 
    		$date =	gmdate('j-m-y h:i:s');

  2. #2
    SitePoint Zealot
    Join Date
    Jan 2011
    Location
    Portland
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    move_uploaded_files?
    coming soon sitejuju.com my new development portfolio

  3. #3
    SitePoint Evangelist captainccs's Avatar
    Join Date
    Mar 2004
    Location
    Caracas, Venezuela
    Posts
    516
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jgetner View Post
    move_uploaded_files?
    Yes!
    PHP Code:
    move_uploaded_file() 
    http://www.php.net/manual/en/functio...oaded-file.php
    Denny Schlesinger
    web services

  4. #4
    SitePoint Evangelist captainccs's Avatar
    Join Date
    Mar 2004
    Location
    Caracas, Venezuela
    Posts
    516
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    The file is not at $_FILES["file"]["name"]

    but at $_FILES["file"]["tmp_name"]
    Denny Schlesinger
    web services

  5. #5
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    731
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Im a bit lost as to what you mean tbh. I have this. Is this target_path I need to change?

    Code:
    		else {
    if(move_uploaded_file($_FILES['uploadLogo']['tmp_name'], $target_path)) {
    		mysql_query("UPDATE users SET logo1='$ref' WHERE id='$myID'");
            echo "Your image ".$filename." has been uploaded";
    } else {
        	echo "There was an error uploading the logo file, please try again!";
    }
    }
    }


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •