xProteuSx Posted March 10, 2010 Share Posted March 10, 2010 I am trying to so something like this: <form id="file_upload_form" method="post" enctype="multipart/form-data" action="upload.php?user_id="+user_id+"\> So essentially I want PHP to upload the file that is being sent, and also get the variable represented by +user_id+ Is this possible? I can't find an answer anywhere. Quote Link to comment https://forums.phpfreaks.com/topic/194740-upload-file-and-send-a-variable/ Share on other sites More sharing options...
teamatomic Posted March 10, 2010 Share Posted March 10, 2010 The userID comes from within. You should have it into a session var when the user logs in. No need to complicate or compromise the form with it. There is a form widget with a type=file that is used for that very purpose, automagically adds the "browse" button, use it. HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/194740-upload-file-and-send-a-variable/#findComment-1024104 Share on other sites More sharing options...
xProteuSx Posted March 10, 2010 Author Share Posted March 10, 2010 Much appreciated teamatomic but ... (yes, there's always a but) ... This is part and parcel of a client-side AJAX type thing ... so I'm sending the variable using Javascript, and using PHP to upload the file and update the database. The update is based on the user_id. Help would be much appreciated (and please DON'T tell me that here is an AJAX forum here, as I have already posted there). Also, what do you mean by type=file ? Do you mean to include it in the form like this? <form id="file_upload_form" type="file" method="post" enctype="multipart/form-data" action="upload.php?user_id="+user_id+"\> Quote Link to comment https://forums.phpfreaks.com/topic/194740-upload-file-and-send-a-variable/#findComment-1024110 Share on other sites More sharing options...
teamatomic Posted March 10, 2010 Share Posted March 10, 2010 form widget for file uploading: <input name="upload" type="file" value="" /> There are various ajax way to do things. I am familiar with prototype, its what I use. But you should set the userID from the server side into the js then. If you are in fact sending the var using javascript why the GET in the action? You might want to look that this tutorial. It uses prototype and APC http://www.phpriot.com/articles/php-ajax-file-uploads HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/194740-upload-file-and-send-a-variable/#findComment-1024119 Share on other sites More sharing options...
xProteuSx Posted March 10, 2010 Author Share Posted March 10, 2010 teamatomic, Thanks for the reference, but I have to come up with something myself, as this is a school assignment. I've tried everything I can think of. I can't be ripping this script apart, or installing it, so unfortunately I won't be able to do anything with this resource. Any other ideas my friend? Quote Link to comment https://forums.phpfreaks.com/topic/194740-upload-file-and-send-a-variable/#findComment-1024139 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.