Jump to content

Recommended Posts

I am trying from several hours to sort and issue but i donno what the problem..

this is the following code i am using

 

mkdir("news_upload/$year/$month/$day",0777);

touch("news_upload/$year/$month/$day/$title.php");

chmod("news_upload/$year/$month/$day/$title.php",0777);

$template = "news_template.php";

$new = "news_upload/$year/$month/$day/$title.php";

copy($template,$new);

 

I have created the directories and given the permission the made a new empty file..

i added permissions to the new made file.. but it didnt apply as i check it.. (PROBLEM)

then i have a template designed with the name news_template.php

wanted to copy this template to the new created file..

the file gets created.. but the new file is not copying the template file on itself..

 

have i done anything rong??? help please?

Link to comment
https://forums.phpfreaks.com/topic/210157-file-copy-problem/
Share on other sites

Instead of:

$template = "news_template.php";
$new = "news_upload/$year/$month/$day/$title.php";
copy($template,$new);

 

Try:

$template = file_get_contents("news_template.php");
$new = "news_upload/$year/$month/$day/$title.php";
file_put_contents($new,$template);

 

I suggest this, because a lot of host disable copy for security reasons.

Link to comment
https://forums.phpfreaks.com/topic/210157-file-copy-problem/#findComment-1096746
Share on other sites

i am still getting the same error message am attaching a screenshot of the error wen i try to access the newly created and used the following code as u said to copy the contents

 

$template = file_get_contents("news_template.php");

$new = "news_upload/$year/$month/$day/$title.php";

file_put_contents($new,$template);

 

here the screen shot

 

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/210157-file-copy-problem/#findComment-1096765
Share on other sites

Check the server error log, it will give you the exact reason.  If that is not possible, for de-bugging purposes only. Place the following at the top of your script.

error_reporting(E_ALL); //over ride error reporting in php.ini
ini_set("display_errors", 1); //print errors to screen.

Link to comment
https://forums.phpfreaks.com/topic/210157-file-copy-problem/#findComment-1096849
Share on other sites

i dont know hot to check the server log.. i did try the code u mentioned for error display

error_reporting(E_ALL); //over ride error reporting in php.ini
ini_set("display_errors", 1); //print errors to screen.

 

but nothing happened it is still giving the same message as be4.. i have uploaded the error msg image in my previous post!

can anyone help?

Link to comment
https://forums.phpfreaks.com/topic/210157-file-copy-problem/#findComment-1096895
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.