Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-24-2012, 05:45 AM   PM User | #1
loopsnhoops
New Coder

 
Join Date: Aug 2011
Posts: 24
Thanks: 6
Thanked 0 Times in 0 Posts
loopsnhoops is an unknown quantity at this point
Exclamation User Upload Problem? Identify Please.

Hi,

I have been having problems allowing users to upload their files on my site into my file manager upload/ directory. When I tried I got this:
Upload: circle-unit-304560.gif
Type: image/gif
Size: 12.181640625 Kb
Temp file: /usr/local/pem/vhosts/113282/tmp/phpTeKNv1
Warning: move_uploaded_file(upload/circle-unit-304560.gif): failed to open stream: Permission denied in /usr/local/pem/vhosts/113282/webspace/httpdocs/upload_file.php on line 25 Warning: move_uploaded_file(): Unable to move '/usr/local/pem/vhosts/113282/tmp/phpTeKNv1' to 'upload/circle-unit-304560.gif' in /usr/local/pem/vhosts/113282/webspace/httpdocs/upload_file.php on line 25 Stored in: upload/circle-unit-304560.gif

The code used was

HTML form:

Code:
<html lang="en">
	
	<body>
		
		<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" /> 
<br />
<input type="submit" name="submit" value="Submit" />
</form>
		
	</body>
</html>
PHP handler:

PHP Code:
<?php
if ((($_FILES["file"]["type"] == "image/gif")
|| (
$_FILES["file"]["type"] == "image/jpeg")
|| (
$_FILES["file"]["type"] == "image/pjpeg"))
&& (
$_FILES["file"]["size"] < 20000))
  {
  if (
$_FILES["file"]["error"] > 0)
    {
    echo 
"Return Code: " $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    echo 
"Upload: " $_FILES["file"]["name"] . "<br />";
    echo 
"Type: " $_FILES["file"]["type"] . "<br />";
    echo 
"Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo 
"Temp file: " $_FILES["file"]["tmp_name"] . "<br />";

    if (
file_exists("upload/" $_FILES["file"]["name"]))
      {
      echo 
$_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      
move_uploaded_file($_FILES["file"]["tmp_name"],
      
"upload/" $_FILES["file"]["name"]);
      echo 
"Stored in: " "upload/" $_FILES["file"]["name"];
      }
    }
  }
else
  {
  echo 
"Invalid file";
  }
?>
Can you identify the problem or offer a solution please. I know this looks like I am asking you to design my website but I can't seem to get past this hurdle.

Thanks, Eric
loopsnhoops is offline   Reply With Quote
Old 04-24-2012, 06:21 AM   PM User | #2
loopsnhoops
New Coder

 
Join Date: Aug 2011
Posts: 24
Thanks: 6
Thanked 0 Times in 0 Posts
loopsnhoops is an unknown quantity at this point
Yeah I double checked
loopsnhoops is offline   Reply With Quote
Old 04-24-2012, 03:34 PM   PM User | #3
loopsnhoops
New Coder

 
Join Date: Aug 2011
Posts: 24
Thanks: 6
Thanked 0 Times in 0 Posts
loopsnhoops is an unknown quantity at this point
Haha I don't know... i've never worked with this hosting site before... Would those be the only two problems? Thanks for the replies
loopsnhoops is offline   Reply With Quote
Old 04-25-2012, 02:43 AM   PM User | #4
SlayerACC
Regular Coder

 
Join Date: Sep 2009
Location: Calgary, Alberta
Posts: 222
Thanks: 45
Thanked 3 Times in 3 Posts
SlayerACC is an unknown quantity at this point
I would think the folder you are moving the file to is not set to be writable.

Check the permissions of the folder to make sure it is set to 777 or 0777

Chmod 777

Thanks SlayerACC.
SlayerACC is offline   Reply With Quote
Users who have thanked SlayerACC for this post:
loopsnhoops (04-25-2012)
Reply

Bookmarks

Tags
form, php, upload, user, warning

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:54 AM.


Advertisement
Log in to turn off these ads.