Profile Photo Upload

Links for php scripts

Moderators: macek, egami, gesf

IamNew
New php-forum User
New php-forum User
Posts: 28
Joined: Fri Nov 04, 2011 6:29 am

Profile Photo Upload

Postby IamNew » Tue Feb 21, 2012 3:25 am

I thinking to create a option whereby a user able to upload photo to their profile in a website.

When a user upload a photo, a folder with the user login ID can be generated inside a root folder "C:\wamp\www". In other words, each user will have a folder store their profile image, folder name will be the user id.

This is my first project on PHP and I am not sure what I have thought of can be possibly done. I will need some aid and guide to move further. I will appreciate and make full use of any references given here. Thanks in advance.

IamNew
New php-forum User
New php-forum User
Posts: 28
Joined: Fri Nov 04, 2011 6:29 am

Re: Profile Photo Upload

Postby IamNew » Wed Feb 22, 2012 2:39 am

Hi,

I did some findings and I come across example 2 in http://www.php.net/manual/en/features.file-upload.post-method.php.

Code:

Code: Select all

<?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.

$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
    echo "File is valid, and was successfully uploaded.\n";
} else {
    echo "Possible file upload attack!\n";
}

echo 'Here is some more debugging info:';
print_r($_FILES);

print "</pre>";

?>


I not really understand this line:

Code: Select all

$uploaddir = '/var/www/uploads/';


Anyone can explain?


Return to “PHP Scripts”

Who is online

Users browsing this forum: No registered users and 8 guests