cpthk Posted January 31, 2008 Share Posted January 31, 2008 Hi: I trying to write a php code. That it will first write to a file(for instance: dynamically create a pdf file) with same filename. After finish writing, it will prompt user to download. My question is if first user is still downloading the file. That's assume the file is pretty big. And a second user run this php file too. What will happen that one is downloading this file and the other is writing this file? Will php finish one request before starting another? PS: I understand that I can write each time to a different filename. But I am trying to write into the same file is because I don't want the server' hard drive one day is full of this file. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/88749-question-on-will-php-finish-one-request-before-starting-another/ Share on other sites More sharing options...
cooldude832 Posted January 31, 2008 Share Posted January 31, 2008 php does it all the time with images without an issue. The way to properly create dynamic file downs is 1) Get the data be it a binary, image file unresized, pdf stuff etc. 2) Place said data in a variable 3) Set headres of the document so that it reflects the files name, size, extension and a download prompt (see the php,net headers function) 4) Place the data in step 2 in to the file's content via an echo or some other manner and your done. Quote Link to comment https://forums.phpfreaks.com/topic/88749-question-on-will-php-finish-one-request-before-starting-another/#findComment-454548 Share on other sites More sharing options...
cpthk Posted February 1, 2008 Author Share Posted February 1, 2008 Thanks for your help. So you are saying php will cache the file in memory and run without any problem? The create dynamic file works for pdf too? I thought it only works for text file, since pdf content is compressed. Just like you open a pdf file in notepad, you will see like random texts. Does dynamic create file work with pdf, too? Any tutorial? Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/88749-question-on-will-php-finish-one-request-before-starting-another/#findComment-454916 Share on other sites More sharing options...
cooldude832 Posted February 1, 2008 Share Posted February 1, 2008 you can make any type of file , the thing is php doesn't have to make a "document" you could in theroy write a C linker/compiler and so forth to write C in a web browser form and then compile it to an .exe file you could download. As long as your file content agrees with what that file is suppose to do. Most of the time the best way is to take the binary safe of the files content (using File_get_content($fileanme,BINARY_SAFE)) and then store it in mysql and recall on demand. Quote Link to comment https://forums.phpfreaks.com/topic/88749-question-on-will-php-finish-one-request-before-starting-another/#findComment-454921 Share on other sites More sharing options...
cpthk Posted February 1, 2008 Author Share Posted February 1, 2008 Is it possible that you can show me an example or tutorial of doing this? I am new to this. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/88749-question-on-will-php-finish-one-request-before-starting-another/#findComment-455002 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.