Helmet Posted July 9, 2008 Share Posted July 9, 2008 Hi, I'm wondering what my options are if I need to upload a file and don't want that process to cause my script to hang (it's a signup script with file upload, but file must then be ftp'd to a different server). I'm thinking the only options are process forking or cron, but thought I'd tap into the freaky wisdom. Thanks, H Link to comment https://forums.phpfreaks.com/topic/113986-solved-is-it-possible-to-prevent-script-hanging-during-ftp-upload/ Share on other sites More sharing options...
discomatt Posted July 9, 2008 Share Posted July 9, 2008 You could always call the script in a 0-width frame/invisible iframe... but the script will still 'hang' until it's job is complete. Link to comment https://forums.phpfreaks.com/topic/113986-solved-is-it-possible-to-prevent-script-hanging-during-ftp-upload/#findComment-585842 Share on other sites More sharing options...
lemmin Posted July 9, 2008 Share Posted July 9, 2008 You can have a separate php file for the process you want to run in the background and use shell_exec() to call it. http://www.php.net/manual/en/function.shell-exec.php Link to comment https://forums.phpfreaks.com/topic/113986-solved-is-it-possible-to-prevent-script-hanging-during-ftp-upload/#findComment-585844 Share on other sites More sharing options...
Helmet Posted July 9, 2008 Author Share Posted July 9, 2008 You can have a separate php file for the process you want to run in the background and use shell_exec() to call it. http://www.php.net/manual/en/function.shell-exec.php But I guess there's no way I can use this to pass values to a function in a separate file, correct? The problem is that I'm processing the image, and then I need to pass its name, location etc to the ftp uploading function. If it's not possible to use shell_exec, what about something like this? I've never tried passing vars in an file include call: include("http://www.mysite.com/index.php?filename=myfile.gif&location=/path/to/file"); Link to comment https://forums.phpfreaks.com/topic/113986-solved-is-it-possible-to-prevent-script-hanging-during-ftp-upload/#findComment-585863 Share on other sites More sharing options...
Helmet Posted July 9, 2008 Author Share Posted July 9, 2008 The crack I was smoking just wore off. Include obviously can't be used for this. Thanks for the suggestions! Link to comment https://forums.phpfreaks.com/topic/113986-solved-is-it-possible-to-prevent-script-hanging-during-ftp-upload/#findComment-585878 Share on other sites More sharing options...
lemmin Posted July 10, 2008 Share Posted July 10, 2008 Why wouldn't it be possible to use shell_exec()? Look into $argv: http://www.php.net/manual/it/reserved.variables.argv.php Also, I had a crazy idea, but I've never tested it. If you send a location header in the middle of your code, it will change the page, but the script will finish on the server. Try something like this: //upload checking code or whatever header("Location: newpage.php"); move_uploaded_file([...]); Link to comment https://forums.phpfreaks.com/topic/113986-solved-is-it-possible-to-prevent-script-hanging-during-ftp-upload/#findComment-586413 Share on other sites More sharing options...
Helmet Posted July 15, 2008 Author Share Posted July 15, 2008 Thank you Link to comment https://forums.phpfreaks.com/topic/113986-solved-is-it-possible-to-prevent-script-hanging-during-ftp-upload/#findComment-590114 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.