Jump to content

[SOLVED] File Creation


Casalen

Recommended Posts

I would like to create a text file containing order information. I'll spare you the rest of the code, but the script creates a directory where people can upload images. With each upload the information of the filename and order is put into two variables, $order_text and $order_table, the first for my text file, the second for display. My goal is to then write to the text file that I made after creating the directory. Unfortunately, fopen is giving me 'file does not exist' errors. The file doesn't exist, but I'm using modes that are supposed to create a file if it isn't found.

 

$handle = fopen("./sales/$num/order.txt", "w");

 

And w+, x, x+, etc. And yes, the directory is chmodded so it's not a permission problem. Help would be greatly appreciated.

Link to comment
https://forums.phpfreaks.com/topic/57231-solved-file-creation/
Share on other sites

Some more code would be appreciated. Just post the whole script, the error line number and which line that is. It will make it alot easier for us since it's hard to guess what "I'm using modes that are supposed to create a file if it isn't found" is exactly :)

Link to comment
https://forums.phpfreaks.com/topic/57231-solved-file-creation/#findComment-282862
Share on other sites

By that I'm referring to the 'w', etc. Sorry I wasn't much more detailed, but my eyes were glazing over at that point. Here is the first part of the script, right up to the first error message- could not open file. The second error message is that it couldn't write to the unopened file, but this is the part that causes me issues. It decides what number is up next for the client's images, $dird tells me if it finished or not. As you can see, the fopen uses the same type of path as the mkdir, which should make it work pretty simply.

 

<?
$num = 1;
$dird = 1;
if($dird == 1){
echo "";}
while($dird == 1){
echo "";
$filename = "http://www.kgpphoto.com/sales/$num";
if(!is_dir("./sales/$num")){
	mkdir("./sales/$num");
	chmod("./sales/$num", 0777);
	$path = "./sales/$num/";
	$dird = 2; }
$num++;
}
$handle = fopen("./sales/$num/order.txt", "w");

Link to comment
https://forums.phpfreaks.com/topic/57231-solved-file-creation/#findComment-283324
Share on other sites

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.