sangoku Posted March 21, 2010 Share Posted March 21, 2010 Is there a way to get the file info before the file transfer starts? like the file name and file size? type.... Quote Link to comment https://forums.phpfreaks.com/topic/196006-how-headers-work-how-to-get-file-info-before-the-uload/ Share on other sites More sharing options...
inversesoft123 Posted March 21, 2010 Share Posted March 21, 2010 it can be done with flash uploads, ActiveX or Java Quote Link to comment https://forums.phpfreaks.com/topic/196006-how-headers-work-how-to-get-file-info-before-the-uload/#findComment-1029560 Share on other sites More sharing options...
sangoku Posted March 21, 2010 Author Share Posted March 21, 2010 I found here that the HTML header actually contains the information i need but i don't know how to intercept the data before the content, the html body which is the content gets transmitted ... http://en.wikipedia.org/wiki/List_of_HTTP_headers Here it says it tells that it sends me the data i nee but how do i intercept it.... QQ Is there any other function in php which can manipulate header data directly? Quote Link to comment https://forums.phpfreaks.com/topic/196006-how-headers-work-how-to-get-file-info-before-the-uload/#findComment-1029561 Share on other sites More sharing options...
inversesoft123 Posted March 21, 2010 Share Posted March 21, 2010 I also found this. http://forums.digitalpoint.com/showthread.php?t=6704 may help you Quote Link to comment https://forums.phpfreaks.com/topic/196006-how-headers-work-how-to-get-file-info-before-the-uload/#findComment-1029562 Share on other sites More sharing options...
PFMaBiSmAd Posted March 21, 2010 Share Posted March 21, 2010 You would need to open a socket connection that listens on a specific port number so that your php script actually handles the upload. See the script and the discussion at the following link for how you might do that - http://www.phpfreaks.com/forums/index.php/topic,284122.0.html What reason do you need this information for? Quote Link to comment https://forums.phpfreaks.com/topic/196006-how-headers-work-how-to-get-file-info-before-the-uload/#findComment-1029563 Share on other sites More sharing options...
inversesoft123 Posted March 21, 2010 Share Posted March 21, 2010 also found this http://blog.joshuaeichorn.com/archives/2005/05/01/ajax-file-upload-progress/ related with AJAX and socket. Reallly helpful will try it shortly. Quote Link to comment https://forums.phpfreaks.com/topic/196006-how-headers-work-how-to-get-file-info-before-the-uload/#findComment-1029565 Share on other sites More sharing options...
sangoku Posted March 21, 2010 Author Share Posted March 21, 2010 bandwidth manipulation and consumption control.... imagine someone sends you a file that is 1 gig big,,, you have limited bandwidth, he manipulates the page so he can send it and,,,, tada,,,, you have a BIG problem... Quote Link to comment https://forums.phpfreaks.com/topic/196006-how-headers-work-how-to-get-file-info-before-the-uload/#findComment-1029577 Share on other sites More sharing options...
sangoku Posted March 21, 2010 Author Share Posted March 21, 2010 Hm................... (1h brain torturing)........... OK the conclusion, it is not possible to monitor the upload... it would be nice but you need to much of server control... not useful for me. but good idea XD i think il go for a hidden swf which only gets the size and generates the sha1 value and sends it XD together with a season cookie info so i can keep track of it. duos someone know how to build such file i doubt it is difficult. Quote Link to comment https://forums.phpfreaks.com/topic/196006-how-headers-work-how-to-get-file-info-before-the-uload/#findComment-1029589 Share on other sites More sharing options...
Mchl Posted March 21, 2010 Share Posted March 21, 2010 If upload file size is a concern for you, you have this php.ini setting: upload_max_filesize Quote Link to comment https://forums.phpfreaks.com/topic/196006-how-headers-work-how-to-get-file-info-before-the-uload/#findComment-1029654 Share on other sites More sharing options...
inversesoft123 Posted March 21, 2010 Share Posted March 21, 2010 if(isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['CONTENT_LENGTH']>209***) $error = 'file is too large !'; This method is really good. Quote Link to comment https://forums.phpfreaks.com/topic/196006-how-headers-work-how-to-get-file-info-before-the-uload/#findComment-1029661 Share on other sites More sharing options...
sangoku Posted March 21, 2010 Author Share Posted March 21, 2010 but is without any purpose.... :-\ because when the file is upload it makes no difference that it is to large or not i intend to use it more like a hack protection and a DOS attack prevention than any control... there are other ways to limit the size like common human sense XD Quote Link to comment https://forums.phpfreaks.com/topic/196006-how-headers-work-how-to-get-file-info-before-the-uload/#findComment-1029676 Share on other sites More sharing options...
PFMaBiSmAd Posted March 21, 2010 Share Posted March 21, 2010 So did you examine the script that was mentioned in the thread I posted a link to above. It has the ability to check the Content-Length header and abort the upload if it is greater than a value you choose. Someone would need to test how well this actually works. AFAIK, when php handles the upload, php does not cause the upload to abort if the size exceeds the various php settings. Quote Link to comment https://forums.phpfreaks.com/topic/196006-how-headers-work-how-to-get-file-info-before-the-uload/#findComment-1029683 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.