Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/194740-upload-file-and-send-a-variable/
Share on other sites

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

 

 

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+"\>

 

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

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.