error message of uploading image

images php coding issues or problems here.

Moderators: macek, egami, gesf

begeiste
New php-forum User
New php-forum User
Posts: 83
Joined: Thu Jun 03, 2004 11:27 am

error message of uploading image

Postby begeiste » Wed May 18, 2005 4:10 pm

Can someone help me to clear what is the exact path that I should put into upload.php, I am so confused.
Basically I have created a folder "photos" inside of www folder, the path that I put is:
"programs file/EasyPHP1-8/www/charlton/photos"

But I got this error message for upload.php:
Notice: Undefined variable: userfile in c:\program files\easyphp1-8\www\charlton\icchurch\upload.php on line 2
Notice: Undefined variable: userfile in c:\program files\easyphp1-8\www\charlton\icchurch\upload.php on line 6

Notice: Undefined variable: userfile_name in c:\program files\easyphp1-8\www\charlton\icchurch\upload.php on line 6
Could not upload image.

In the upload.php page: this is all code that I put below:
<?php
if($userfile=="none")
{
echo"No file specified";
exit;
}
if(move_uploaded_file($userfile,"\\photos\\".$userfile_name)){
echo"Your image has been uploaded.";}
else{ echo"Could not upload image.";}
?>

And I created a html form:
<body>
Basic image upload:<br>
<form action="upload.php" method="post" enctype="multipart/form-data" name="form1">
<input type="file" name="file">
<br>
<input type="submit" name="Submit" value="upload image">
</form>
</body>

I am not sure if I need to make database connected in the upload.php or not necessary?

Thanks alot!

Beckmann

User avatar
gesf
Moderator
Moderator
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden
Contact:

Postby gesf » Wed May 18, 2005 5:01 pm

That mean your userfile and userfile_name variables aren't being initializated.
Example:

Code: Select all

<?php

// Where are your variables coming from !?

// This will cause an "Undefined variable" Notice Error
if($userfile == "none") {
   echo"No file specified";
   exit;
}

// This one won't
$userfile = 'none';

if($userfile == "none") {
   echo"No file specified";
   exit;
}
 
?>

begeiste
New php-forum User
New php-forum User
Posts: 83
Joined: Thu Jun 03, 2004 11:27 am

Postby begeiste » Wed May 18, 2005 8:06 pm

Thanks alot man.


Return to “PHP coding => Images”

Who is online

Users browsing this forum: No registered users and 2 guests