Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP safe_mode file uploads HELP!!!
Old 07-28-2008, 06:58 PM PHP safe_mode file uploads HELP!!!
digitalfusion's Avatar
Skilled Talker

Posts: 73
Name: Martin
Location: Fife, Scotland
Trades: 0
Hi all,

I'm totally puzzled as to how i can fix this problem. It appears to me my web host must have safe mode enabled as i get this error when trying to use move_uploaded_file to put a file onto my server.

Warning: move_uploaded_file() [function.move-uploaded-file]: SAFE MODE Restriction in effect. The script whose uid is 32310 is not allowed to access /home/martin/public_html/admin/tutorials/PHP owned by uid 99 in /home/martin/public_html/admin/addtut.php on line 47

My upload script uses the following code:

PHP Code:
$filename="".$_FILES["file"]["name"]."";
$tutfilename="www.tornadodesigns.co.uk/admin/tutorials/".$tutcatname."/".$_FILES["file"]["name"]."";
if (
$_FILES["file"]["error"] > 0)
  {
  echo 
"Error: " $_FILES["file"]["error"] . "<br />";
  }
else
  {
  echo 
"Your file has been uploaded!<br />";
  echo 
"Upload: ".$filename."<br />";
  echo 
"Size: " . ($_FILES["file"]["size"] / 1024 8) . " MegaBytes<br />";
  echo 
"<br>";
  }

if (
file_exists("tutorials/".$tutcatname."/".$filename.""))
      {
      echo 
"".$filename " already exists. ";
      }
    else
      {
      
move_uploaded_file($_FILES["file"]["tmp_name"],
      
"tutorials/".$tutcatname."/".$filename."");
      
      
        
// add to the database
        
$addtuttodb=mysql_query("INSERT INTO tutorials VALUES (NULL, '$tutname', '$tutfilename', '$tutcatid'");
        if(
$addtuttodb==0) {
            echo 
"There was a problem adding the tutorial to the database!";
        } else {
            echo 
"The tutorial has been successfully added to the database!";
        }
    } 
Please help i'm about to give up with it here!!

Regards,
Martin
__________________
---------------------------------------------------

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
digitalfusion is offline
Reply With Quote
View Public Profile Visit digitalfusion's homepage!
 
 
Register now for full access!
Old 07-29-2008, 07:07 AM Re: PHP safe_mode file uploads HELP!!!
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
Move to some less crappy hosting
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 07-29-2008, 07:10 AM Re: PHP safe_mode file uploads HELP!!!
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
Also I can try to guess that you created your directory through ftp, and on your server the ftp daemon and the one who runs php (most likely it is apache) have different uids. So the ftp creates the directory that cannot be then written by apache/php. Create your directories from the script to make it have correct privileges.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 07-29-2008, 08:25 AM Re: PHP safe_mode file uploads HELP!!!
digitalfusion's Avatar
Skilled Talker

Posts: 73
Name: Martin
Location: Fife, Scotland
Trades: 0
It's because the directory was created using php therefore the php interpreter had the writeable owner writes to the directory, so i've had to manually create the directorys and upload the files via the script this works fine like that so am leaving it like that, but i've stumbled on another problem now.

I'm trying to include the uploaded file (html file) into a page using php includes, however the page is just blank after the include.

The script works without the include and the included file is correct and working.

my code for the page is:

PHP Code:

// get tutorial info
$tutorialid=$_REQUEST['tutorialid'];

$gettutorialinfo=mysql_query("SELECT * FROM tutorials WHERE tutorialid='".$tutorialid."'");
while(
$tutorial=mysql_fetch_array($gettutorialinfoMYSQL_ASSOC)) {
    
$tutorialfilename="".$tutorial['tutorialfile']."";
    
$tutorialcatid="".$tutorial['tutcatid']."";
    
$getcatinfo=mysql_query("SELECT * FROM tutorial_cats WHERE tutcatid='".$tutorialcatid."'");
    while(
$cat=mysql_fetch_array($getcatinfoMYSQL_ASSOC)) {
        
$tutcatname="".$cat['tutcatname']."";
    }
    
$tutorialname="".$tutorial['tutname']."";
    
$tutorialfile="http://www.tornadodesigns.co.uk/admin/tutorials/".$tutcatname."/".$tutorialfilename."";
   
}
// Include the tutorial file
include($tutorialfile);


?> 
Any help would be greatly appreciated

Regards,
Martin
__________________
---------------------------------------------------

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
digitalfusion is offline
Reply With Quote
View Public Profile Visit digitalfusion's homepage!
 
Old 07-29-2008, 02:59 PM Re: PHP safe_mode file uploads HELP!!!
Skilled Talker

Posts: 77
Name: Bill Benson
Location: Florida
Trades: 0
you are including a variable, not a file.
bill benson is offline
Reply With Quote
View Public Profile
 
Old 08-02-2008, 05:07 PM Re: PHP safe_mode file uploads HELP!!!
digitalfusion's Avatar
Skilled Talker

Posts: 73
Name: Martin
Location: Fife, Scotland
Trades: 0
Quote:
Originally Posted by bill benson View Post
you are including a variable, not a file.
yes but the variable defines the location of the file, in any case i've fixed it i just needed to set an absolute path to the file instead of a http path.

Thanks for your help
Regards,
Martin
__________________
---------------------------------------------------

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
digitalfusion is offline
Reply With Quote
View Public Profile Visit digitalfusion's homepage!
 
Reply     « Reply to PHP safe_mode file uploads HELP!!!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.24774 seconds with 12 queries