file exist check failing |
[eluser]bhakti.thakkar[/eluser]
hi all, some PDF's generated by my application on click of "save and print" are directly stored on the server (remote). there is a view to see the PDF's generated till date and the user can access that PDF as and well he wants. but there are cases when the file is move to a different location or is deleted because of some reason. i want to check where the file still resides on the specified path or not.. how can i do so. i tried if( file_exists($source)) but it doesnt work. how can i do this also tried below as i am accessing files on remote server: Code: if (fclose(fopen($source, "r"))) Thanks
[eluser]TheFuzzy0ne[/eluser]
If neither are working, then you have one of two problems. a) Your file has incorrect permissions set, or b) You are not looking in the right place for your file. I would recommend you echo $source into your log file, and then SSH over to your server if you can, cd to your Web directory, and then cat the file: cat whatever/came/from/source/variable It will either tell you the file doesn't exist in which case it's a problem with your script. Otherwise it's probably a problem with permissions. If you don't have SSH access to your server, you can use "getcwd()" in your script to ascertain the working directory, and then you can work from there. Hope this helps.
[eluser]bhakti.thakkar[/eluser]
Hello, My files have the chmode 777 permissions set Also i am looking into the right folder as the other files that are pointing to the same folder work and open well. this is only for the case where the file has been deleted or moved due to some reason. i dont want the user to see " page cannot be displayed " error
[eluser]xwero[/eluser]
Did you check the $source variable to make sure it has the full filepath for the file?
[eluser]TheFuzzy0ne[/eluser]
Oh, hang on. You're accessing files on a remote server? Please could you elaborate? Are they accessible via HTTP, FTP?
[eluser]bhakti.thakkar[/eluser]
hello, its via HTTP in config.php i have defined Uploadfiles_url as $config['UploadFiles_url'] = "http://IP_ADDRESS/UPLOADFOLDER/"; <? foreach($query->result() as $row): $source=$this->config->item('UploadFiles_url')."PDF_files/"; ?> <td><a >AttachedFile_VC?>" target="_blank"><?=$row->AttachedFile_VC;?> </a></td> Hope its clear * [href="<?=$source.$row->AttachedFile_VC" ] and many files do get opened by the above method. but i dont want to display page not found error for those files which now do not reside on the specified path any more Thanks
[eluser]TheFuzzy0ne[/eluser]
Is there any reason you can't use my latest creation: http://ellislab.com/forums/viewthread/106556/? If the remote server says the file can't be found, then the function returns FALSE and you can do whatever you need to do.
[eluser]bhakti.thakkar[/eluser]
hi, let me try putting the function is_working_url($url) and see whats happening. i will keep you updated on it. Thanks
[eluser]bhakti.thakkar[/eluser]
hi, [quote author="TheFuzzy0ne" date="1235413877"]Is there any reason you can't use my latest creation: http://ellislab.com/forums/viewthread/106556/? If the remote server says the file can't be found, then the function returns FALSE and you can do whatever you need to do.[/quote] as suggested i tried using : Code: function is_working_ur($url) but it doesnt help as its anyways returning true for all the cases. i have done all required validations for clean urls hope i get some help ALSO TO BE NOTED THAT THE FILES ARE RESIDING ON THE SAME SERVER AS OF THE APPLICATION. I AM SORRY I DID A MISTAKE OF SPECIFYING THAT THE FILES ARE ON REMOTE SERVER. Thanks |
Welcome Guest, Not a member yet? Register Sign In |