Jump to content

fopen() file exists but server reports error?


xcandiottix

Recommended Posts

I've just inserted some code to make a directory, a index.html file, and a user.xml file. After I run the code I get "success." I check the file browser online and my file and directory exist, I can open and view the files. I switch to dreamweaver and check remote view and the files exist; I download them and they are all proper.

 

Then I try typing in http://..location of file... and I get a 404.

 

What am i missing? Do I need to declare file permissions when I create the directory & files?

 

		$username = $row['db_Username'];
		//make user directory
		$userdirectory = "/html/users/".$username."";
		mkdir($userdirectory, 0700);
		//make user index file
		$create = "/html/users/".$username."/index.html";
		$handler = fopen($create, 'w') or die("Error: Set up has encountered an error. Please try again.");
		$string = "<html>Forward to member launch pad with user name</html>";
		fwrite($handler, $string);
		fclose($handler);
		//make user XML
		$create = "/html/users/".$username."/".$username.".xml";
		$handler = fopen($create, 'w') or die("Error: Set up has encountered an error. Please try again.");
		$string = "XML data";
		fwrite($handler, $string);
		fclose($handler);
		echo "<br>";
		echo '<a href="http://www.site.com/users/'.$username.'">http://www.site.com/users/'.$username.'/';
		mysql_close($con);

 

http://www.site.com/users/username/index.html = 404

If you have godaddy and ran into the same problem add:

 

chmod($userdirectory, 0755);

 

after

 

//make user directory

$userdirectory = "/home/content/q/1/w/q1w2e3r4t5y6u7/html/users/".$username."";

mkdir($userdirectory, 0700);

---here---

 

For why this works:

http://php.net/manual/en/function.chmod.php

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.