GetDotted Domains

Viewing Thread:
"still have read/write permissions problems with freeola folders"

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Thu 09/08/07 at 22:41
Regular
Posts: 12
ok this is my problem..

i have written the php code to upload pictures to my htdocs/images folder.

this works fine images are being sent to the folder and then a link is sent to my mysql so as to retrieve them with a mysql command.

the images folder has read/write permissions set to all users.

but this is this the problem....

images are not shown because when i right click and view image properties of the pictures in the images folder they are being uploaded with no read/write permissions.

When i change these to allow read/write they are then shown in my gallery page.

can anyone help please
Fri 10/08/07 at 18:33
Regular
"Devil in disguise"
Posts: 3,151
Not related to your chmod problems but have a look at mysql_real_escape_string

Inserting POST/GET data directly into DB queries without escaping or checking them in some fashion is highly inadvisable.
Fri 10/08/07 at 18:20
Regular
Posts: 12
this is the code where can i change the chmod settings please




<?php

//This is the directory where images will be saved
$target = "images/";
$target = $target . basename( $_FILES['photo']['name']);

//This gets all the other information from the form
$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$pic=($_FILES['photo']['name']);
// Connects to your Database
mysql_connect("mysql.freeola.net", "sr------", "--------") or die(mysql_error()) ;
mysql_select_db("sr------") or die(mysql_error()) ;
//Writes the information to the database
mysql_query("INSERT INTO `employees` VALUES ('$name', '$email', '$phone', '$pic')") ;
if(move_uploaded_file ($_FILES['photo']['tmp_name'], $target))
{
//Tells you if its all ok
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
}
else {
//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}
?>
Fri 10/08/07 at 13:55
Regular
Posts: 12
thanks eccles appreciate it
Fri 10/08/07 at 13:45
Staff Moderator
"Aargh! Broken..."
Posts: 1,408
0644 should be sufficient.
The way everyone can read the file but only the owner (PHP) can write to it (overwrite it). Scripts that actually do something should be chmodded to 0755 (owner can read, write and execute and everyone else can just read and execute). You shouldn't need to use 0777 permissions.
Fri 10/08/07 at 13:24
Regular
Posts: 12
thanks eccles so because the uploaded pictures arent showing bascially put that code in but change the settings to 777?
Fri 10/08/07 at 11:41
Staff Moderator
"Aargh! Broken..."
Posts: 1,408
You could just use the chmod command in PHP on each file after it is saved.

<?php
$upload_directory = '/var/home/sr0000000/htdocs/images/';
$uploadfile = $upload_directory . basename($_FILES['userfile']['name']);
move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile);
chmod($uploadfile, 0644);
?>
Thu 09/08/07 at 22:41
Regular
Posts: 12
ok this is my problem..

i have written the php code to upload pictures to my htdocs/images folder.

this works fine images are being sent to the folder and then a link is sent to my mysql so as to retrieve them with a mysql command.

the images folder has read/write permissions set to all users.

but this is this the problem....

images are not shown because when i right click and view image properties of the pictures in the images folder they are being uploaded with no read/write permissions.

When i change these to allow read/write they are then shown in my gallery page.

can anyone help please

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Very pleased
Very pleased with the help given by your staff. They explained technical details in an easy way and were patient when providing information to a non expert like me.
Just a quick note to say thanks for a very good service ... in fact excellent service..
I am very happy with your customer service and speed and quality of my broadband connection .. keep up the good work . and a good new year to all of you at freeola.
Matthew Bradley

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre
Feedback Close Feedback

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.