Hi, I've tried to write data in txt file form.php <table cellpadding="0" cellspacing="0" style="margin-left:100px; margin-top:100px"> <tr> <td> <form action="processscript.php" method="post"> <textarea rows="20" cols="40" name="content" style="font-family:verdana"> <? $fn = "b.txt"; print htmlspecialchars(implode("",file($fn))); ?> </textarea> <input name="fname" type="hidden" value="<?php echo $fn; ?>"><br> <input type="submit" value="Keisti" style="font-family:verdana; margin-top:10px"> </form> </td> PHP: processscript.php <? $fn = $_POST['fname']; $content = stripslashes($_POST['content']); $fp = fopen($fn,"w") or die ("Error opening file in write mode!"); fputs($fp,$content); fclose($fp) or die ("Error closing file!"); echo "<meta http-equiv=\"refresh\" content=\"0; url=form.php\" />\n"; ?> PHP: everything ran smooth on my pc, but i got error after upload of file onto server.
Did you check if the file permissions allow you to write to that file? Or is that file behind some authentication system like .htaccess password protection?
file permissions allows to write, because i could do it in my pc. code of .htaccess SetEnvIfNoCase Referer "^http://(www\.)?my_page_name\.(puslapiai|projektas)\.lt" locally_linked=1 <FilesMatch "\.(gif|png|jpg|jpeg)$"> Order allow,deny Allow from env=locally_linked </FilesMatch> PHP:
DeFacto: that's where you're wrong, there is a difference between a Windows (local) and a Linux (server). On Windows, all files are writable by default. On Linux, you have to specify this per file, by chmodding it correctly. To make a file writable, you should chmod it 777. .htaccess has absolutely no influence or whatsoever on your PHP script.
OK...So first make sure the PHP settings are allowing it. After that, you might want to "chown" that directory and set the permissions in the 700s, so your system can always write to it.
In your FTP client, look for something called permissions, most of the time it is Right click -> File permissions/properties. If you are allowed to enter a number here, enter 0777. If you cannot enter a number, then check off all checkboxes (should be nine in total). Since the file you are writing to is dynamicly inputted, you should chmod the whole directory where you are writing to 0777.
If you have cpanel you can change permissions using the file manager in cpanel, needs to be 777 for both