jeboy Posted January 3, 2008 Share Posted January 3, 2008 Is there a way to store an uploaded file to a variable rather than copying or moving it to a specified location in the server? Quote Link to comment https://forums.phpfreaks.com/topic/84221-how-to-store-an-uploaded-file-to-a-variable-in-php/ Share on other sites More sharing options...
teng84 Posted January 3, 2008 Share Posted January 3, 2008 when you move upload file the file it will be temporary saved in temp file and you can use that temp DIR as the vaiable value.. Quote Link to comment https://forums.phpfreaks.com/topic/84221-how-to-store-an-uploaded-file-to-a-variable-in-php/#findComment-428926 Share on other sites More sharing options...
jeboy Posted January 3, 2008 Author Share Posted January 3, 2008 when you move upload file the file it will be temporary saved in temp file and you can use that temp DIR as the vaiable value.. So how do I use that to upload the file in later time? Quote Link to comment https://forums.phpfreaks.com/topic/84221-how-to-store-an-uploaded-file-to-a-variable-in-php/#findComment-428954 Share on other sites More sharing options...
teng84 Posted January 3, 2008 Share Posted January 3, 2008 you may put the temp directory in a session or cookie so after all the transaction is doen you will just have to get that file in your temp dir Quote Link to comment https://forums.phpfreaks.com/topic/84221-how-to-store-an-uploaded-file-to-a-variable-in-php/#findComment-428955 Share on other sites More sharing options...
jeboy Posted January 3, 2008 Author Share Posted January 3, 2008 you may put the temp directory in a session or cookie so after all the transaction is doen you will just have to get that file in your temp dir Can you give me a sample basic code for that? What I did is, I store the tmp_name to a session variable then after the user completes a series of form process, I do the upload. i.e. form.php $_SESSION['_FILETMP'] = $_FILES['file_upload']['tmp_name']; $_SESSION['_FILENAME'] = $_FILES['file_upload']['name']; upload.php copy($_SESSION['_FILETMP'], $_SESSION['_FILENAME']); Quote Link to comment https://forums.phpfreaks.com/topic/84221-how-to-store-an-uploaded-file-to-a-variable-in-php/#findComment-428975 Share on other sites More sharing options...
teng84 Posted January 3, 2008 Share Posted January 3, 2008 did you try that, that should work Quote Link to comment https://forums.phpfreaks.com/topic/84221-how-to-store-an-uploaded-file-to-a-variable-in-php/#findComment-428976 Share on other sites More sharing options...
jeboy Posted January 3, 2008 Author Share Posted January 3, 2008 did you try that, that should work Yes, but it doesn't work, it says: failed to open stream: No such file or directory Quote Link to comment https://forums.phpfreaks.com/topic/84221-how-to-store-an-uploaded-file-to-a-variable-in-php/#findComment-428979 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.