File permissions driving me crazy!!

This is a discussion on "File permissions driving me crazy!!" within the PHP Forum section. This forum, and the thread "File permissions driving me crazy!! are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old May 31st, 2007, 11:14
New Member
Join Date: May 2007
Location: liverpool
Age: 22
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
File permissions driving me crazy!!

Can anyone see whats wrong with this PHP code?!!

Ive been told its down to permission problems as i just get the error message thats in the else statement.

But ive set all of the permissions so full and im still having the same problem.

PHP: Select all

             include "conn.php";
            
            
//rename file
            
$sql=mysql_query("SELECT num FROM num");
            if(!
$sql)
                {    echo 
mysql_error();
                }
            
            else {
            
$num=mysql_result($sql00);
            echo 
'num is '.$num.'<p>';
            
$num++;
            }
            
            
//set directory
            
$target="Images/pics/";
            
$target=$target.$num.'.jpg';
            
$mode=0777;
            
chmod($target$mode);
            
            
$res=mysql_query("UPDATE num SET num = $num");
            
            
//check dimensions and filetype, 200px and jpg
            
$tmpname=$_FILES['file']['tmp_name'];
            
$size=getimagesize($tmpname);
            
            
$filetype=$size[2];

            if(
$filetype!=2)
                {
                    echo 
"ERROR: All images must be a .jpg";
                }
            
            
            
//transfer file and insert into databases    
            
elseif(move_uploaded_file($_FILES['file']['tmp_name'], $target))
                {
                    
$name=$num;
                    
                    
$select=$_POST['select'];
                    
$pic=$_POST['pic'];
                    
                    
$res=mysql_query("UPDATE gallery SET $pic='$name' WHERE name = '$select'");
                    if(!
$res)
                        {
                            echo 
'<p>'.mysql_error();
                        }
                    echo 
mysql_affected_rows($res).'<p>Image '.$name.'.jpg uploaded to '.$select.' '.$pic;

                }
            
            else
                {
                    echo 
'error';
                } 
Reply With Quote

  #2 (permalink)  
Old May 31st, 2007, 12:53
Junior Member
Join Date: May 2007
Location: United Kindom, London and the South East
Age: 17
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Bradster
Re: File permissions driving me crazy!!

What is the error message you are getting?
Reply With Quote
  #3 (permalink)  
Old May 31st, 2007, 20:53
New Member
Join Date: May 2007
Location: liverpool
Age: 22
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: File permissions driving me crazy!!

It just says 'error'. which is from the else statement.
Reply With Quote
  #4 (permalink)  
Old Jun 1st, 2007, 00:03
Reputable Member
Join Date: May 2006
Location: Northampton, UK
Posts: 399
Thanks: 0
Thanked 0 Times in 0 Posts
Re: File permissions driving me crazy!!

Code: Select all
elseif(move_uploaded_file($_FILES['file']['tmp_name'], $target))


an elseif must contain an argument .... this doesnt look like an argument to me... more like a command

eg:
Code: Select all
if($filetype!=2)(
code_here
}
elseif ($filetype > 3 ){
code_here
}
else {
code_here
}


Last edited by Accurax; Jun 1st, 2007 at 00:07.
Reply With Quote
Reply

Tags
chmod, file upload

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
CSS Layout Issue (in Firefox only)... probably simple but its driving me crazy! alfandango Web Page Design 4 Mar 8th, 2008 17:11
Directory Permissions jewelz Website Planning 10 Mar 2nd, 2007 16:43


All times are GMT. The time now is 02:00.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43