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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.