<?php mkdir("amit",0755) or exit("Unable to create folder"); chmod("amit",0777) or exit("Unable to change mode"); $file=fopen("amit/index.htm","x") or exit("Unable to create file!"); fwrite($file,"Hello world!"); chmod("amit",0755); ?> Probably you understand work of the piece of code. I would need to create a directory e.g. "amit", change mode using chmod() if required to create a file named "index.htm" inside "amit" folder and writing few content during creation of "index.htm" and then change mode again of the folder to "755" for security. This script works very finely on my one site but same script does not work on another site hosted on different hosting server. no help from hosting side. I would need to find any alternative of the code. please guide me how can I solve the problem. I've also tried to use ftp functions also. it connects to the ftp but fail to change mode "ch mode" or create files e.g. "index.htm" properly. Please help me. thank you very much for your valuable comments, suggestions and advices in advance. Kindest regards to all php gurus Amit
Remember Blogger.com ? if you run your own blog site and you need to give ftp detail when setting up your blog site and blogger does the same thing .. it creates folders, creates .html files using php.. how do they do it ?
They do the same thing that you are doing. But they are running dedicated servers, they are not on shared hosting. Do you have dedicated server or shared hosting? Ask your host if they have not disabled these functions.
whether they are running bloggers.com on dedicated server but a user that has his own site 99% times on shared server like me. they can not complain .."change the hosting and then bloggers.com will work for you". they work it through ftp function but how is the question ?
is there any one who could solve my problem .. I would happy to pay $ provided it works. directory creation , and writing files are resticted e.g. mkdir() , chmod() , even fopen() is not working when mode sets to "w" ( writing ).. fopen works if it sets to "r" (read only). Kindly advice if there is any alternative through ftp functions ..or what ?
What about : creating a directory from your cPanel or your FTP client manually (not by mkdir() PHP function), chmod the directory as writable, and creating some files there with PHP function.