-
[RESOLVED] Chmod?
Hi everyone,
I've been wanting to write to a text file with Flash/PHP and apparantly the code I'm using works. However, someone mentioned something that the reason mine won't work was something to do with CHMOD?
What is that exactly, and how would I go about allowing Flash/PHP to do it's thing, so it can save information to text files?
If you're interested, my Flash and PHP codes are as follows:
Code:
myData = new LoadVars();
submit.onRelease = function() {
myData.Name = Name.text;
myData.sendAndLoad("save.php",myData,"POST");
};
PHP Code:
<?php
$name = $_POST['Name'];
$toSave ="Name=".$name;
$myfile = fopen("saveLocal.txt","w");
$fp = fwrite($myfile,$toSave);
fclose($myfile);
?>
Thanks. :)
-
When someone refers to chmod, they're talking about the privileges associated with a file.
There are 3 possible groups:
User, Group, Others
And they can be mixed with 3 types of permission levels:
Read, Write, Execute
So really, what they mean is that the file you're trying to write to doesn't have the write privileges for your web server to manipulate it.
Without getting real complicated into figuring out which user your web server process is, it would be best to give write privileges for that file to everyone.
You can do this through your FTP client. Instructions will vary for each client, but there's probably a way to right click the file, View Properties, and somewhere about permissions.
If you had SSH access, you can actually run the chmod command on the file by doing:
Code:
chmod a+w saveLocal.txt
Or last, you can do it via PHP:
PHP Code:
chmod('saveLocal.txt', 0777); //gives full permissions for anyone to do anything to the file. Kinda insecure doing it this way.
-
Hi,
beware: without a file, you cannot set its permissions ...
and without permissions, you cannot even create a file
method 1: upload an empty file saveLocal.txt, and then use ftp to change permissions
method 2: create a folder in ftp, change permissions (would be r,w,x in all groups here), and modify the script to save to a file in that folder
Musicman
-
That's really helpful. :)
So I uploaded the three files: the SWF, PHP and the TXT and individually selected the properties menu and for the sake of it, checked everything under permissions. I even did it to the properties of the folder they're in.
... Still nothing. Could it be a firewall thing, I wouldn't think so?
-
It wouldn't be a firewall thing, and no other files should need any write privileges. If you have a text file on the server and you're giving it full permissions (777), then there shouldn't be an issue. Are you sure you have the file in the correct place?
It's kinda hard to know what's going on. Care to lay out your folder structure and list which files have which permissions?
-
3 Attachment(s)
Okay, so this is the layout. I'm using webspace provided by my university. I log into the ftp at: ftp://individual.utoronto.ca/
In there I have a folder called saving in which there are three files:
Test.swf, save.php and saveLocal.txt, each with their permissions set to full permissions including the folder itself. Here's some screenshots of what's going on.
The link to the actual file is http://individual.utoronto.ca/ostil_...aving/Test.swf. The top input box should save whenever you press the blue button.
-
That's very odd man. I'd check in with the system admin for your server, because something is wrong. If the file has write privileges... it should be able to be written to. I don't know how that can be wrong.
-
Well at least the good news is that technically it should work. That would mean it would be the University web space that would be causing a problem. I just needed to know how to do it for a small project I'm working on, I'll find something else to host it.
Thanks a lot though, you've been a great help. :)
-
Hi,
trying to watch messages right from the server, I saw:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>405 Method Not Allowed</TITLE>
</HEAD><BODY>
<H1>Method Not Allowed</H1>
The requested method POST is not allowed for the URL /ostil_matthew/saving/save.php.<P>
</BODY></HTML>
This means that your university webspace does not properly support php. Time to talk to the admin....
Musicman
-
Oh well that confirms it. I'm just going to use some free file hosting, I just need something quick and easy to post a very simple program to store stuff. Thanks alot! :)