Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1505 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

Hey, I have a quick question

Thread title: Hey, I have a quick question
Closed Thread    
    Thread tools Search this thread Display Modes  
12-01-2007, 04:29 AM
#1
Xphic is offline Xphic
Status: I love this place
Join date: Sep 2007
Location:
Expertise:
Software:
 
Posts: 523
iTrader: 13 / 100%
 

Xphic is on a distinguished road

  Old  Hey, I have a quick question

I just dont know whats wrong, heres the warning

Warning: move_uploaded_file(uploads/step6small.png) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/xphic/public_html/index.php on line 81

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpU8rYa0' to 'uploads/step6small.png' in /home/xphic/public_html/index.php on line 81

heres the code

PHP Code:
<?

include('config.php');
include(
'design/header.php');

if (isset(
$_SESSION['loggedin']) == "256"){

include(
'design/navigation-in.php');

} else {

include(
'design/navigation-out.php');

}

?>
<h2 id="upload">Upload an image; Browse for your image, then click upload!</h2>

<div id="content">
<?

### No form was posted, show upload form
include('uploadform.htm');

if (
$HTTP_POST_VARS['submit']) {
### Form has been posted

    
if (isset($_SESSION['loggedin']) == "256"){

        
$username mysql_real_escape_string($_SESSION['username']);
        
$password mysql_real_escape_string($_SESSION['password']);

        
$getfilesize mysql_query("SELECT * FROM sizerestrictions WHERE usergroup = 'members'");
        while(
$v mysql_fetch_array($getfilesize)){

        
$maxfilesize $v['limit'];
        
            
$getmemberfile mysql_query("SELECT * FROM members WHERE username = '".$username."' && password = '".$password."'");
            while(
$f mysql_fetch_array($getmemberfile)){

            
$uploaddir "uploads/".$f['directory'];

            }

        }

    } else {
    
        
/////$getfilesize = mysql_query("SELECT * FROM sizerestrictions WHERE usergroup = 'guests'");
        /////while($v = mysql_fetch_array($getfilesize)){

        /////$maxfilesize = $v['limit'];
        
$uploaddir $originaldir;

        
/////}

    
}

    if (
$HTTP_POST_FILES['file']['size'] < $maxfilesize){
    
### File under max file size
    
        
$rand rand(1,9999);

        if (
$HTTP_POST_FILES['file']['type'] == "image/jpeg" || $HTTP_POST_FILES['file']['type'] == "image/pjpeg" || $HTTP_POST_FILES['file']['type'] == "image/gif" || $HTTP_POST_FILES['file']['type'] == "image/png"){
        
### File is JPG, JPEG, PNG or GIF

                
if (is_file($uploaddir."/".$_FILES['file']['name'])){
                
### File already exists, rename and upload

                    
$newfile $rand.strtolower($_FILES['file']['name']);

                    
move_uploaded_file($_FILES['file']['tmp_name'],"".$uploaddir."/".$newfile);

                    
$error "0";

                } else {
                
### One of a kind file, upload

                    
$newfile $_FILES['file']['name'];

                    
move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir."/".$_FILES['file']['name']);

                    
$error "0";                

                }

                    
### Success, file was uploaded
                    
include('success.php');    

        } else {
        
### File does not match allowed types
        
        
$error "Your file is not an acceptable file type";

        }

    } else {
    
### File to large

    
$error "Your file is too large";

    }

}

if (
$error !== "0"){
### If error is present, display

print "<h4 class='error' style='margin-top: 10px'>".$error."</h4>";

}

include(
'ad.php');

include(
'design/footer.php');

?>

12-01-2007, 04:30 AM
#2
Tech07 is offline Tech07
Status: I'm new around here
Join date: Jun 2007
Location: Canada
Expertise:
Software:
 
Posts: 17
iTrader: 0 / 0%
 

Tech07 is on a distinguished road

  Old

did you chmod uploads/ to 777

12-01-2007, 04:30 AM
#3
brucet is offline brucet
Status: I'm new around here
Join date: Jun 2007
Location: Michigan
Expertise:
Software:
 
Posts: 1
iTrader: 0 / 0%
 

brucet is on a distinguished road

  Old

Does the webserver username have write permissions on the "uploads" directory? Does the uploads dir exist? Can you specify an absolute path instead of relative to avoid ambiguity?

12-01-2007, 12:13 PM
#4
Jeff Andersen is offline Jeff Andersen
Status: Superstar
Join date: Apr 2005
Location:
Expertise:
Software:
 
Posts: 4,449
iTrader: 10 / 100%
 

Jeff Andersen is on a distinguished road

  Old

As the other two have said, it definitely sounds as if you didn't go in and CHMOD the upload directory to be able to be written.

Regards,
Jeff

12-01-2007, 01:18 PM
#5
JamesW is offline JamesW
Status: Member
Join date: Mar 2006
Location: London, Ontario, Canada
Expertise: Design & Photograph
Software: Photoshop, Dreamweaver, Chrome
 
Posts: 182
iTrader: 1 / 100%
 

JamesW is on a distinguished road

Send a message via MSN to JamesW Send a message via Skype™ to JamesW

  Old

CHMOD does seem to be your issue. In your ftp client right click the uploads director, and find where it says either CHMOD, File Preferences, or something along that lines. You should get either a bunch of check boxes with a number in top, or maybe just a spot with a number. The default is 644.

You want to change it to:
766 so that the root an execute the move command, and that others and groups can write to the folders. If that does not work try 777 which lets each section do everything.

12-01-2007, 02:08 PM
#6
Xphic is offline Xphic
Status: I love this place
Join date: Sep 2007
Location:
Expertise:
Software:
 
Posts: 523
iTrader: 13 / 100%
 

Xphic is on a distinguished road

  Old

thanks a lot guys for the help, it worked, I changed it to 777

12-01-2007, 10:00 PM
#7
Tech07 is offline Tech07
Status: I'm new around here
Join date: Jun 2007
Location: Canada
Expertise:
Software:
 
Posts: 17
iTrader: 0 / 0%
 

Tech07 is on a distinguished road

  Old

No problem

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed