Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Ronin Magus

browser-based uploading

This topic is 5737 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve been put in charge of a project here at work which I will be developing over the next few months. All the technology involved is really rather simple (a bunch of SQL tables, web pages/server, browser clients, etc.) I''ve had more than enough experience with those technologies to design and implement a working project, which I''ve done many times in the past. The project is basically an in-house inventory/computer maintenance/team project management program that will simplify MANY of our daily operations in my department. But there is one certain feature which I don''t know how to go about implementing...Whenever a piece of hardware that requires a driver is added to the inventory, there needs to be a browser-based upload form that allows the user to upload the driver installation files to the server so they will be there for download and later use, since we reuse old hardware all the time. I''m basically looking to create something along the lines of hotmail''s file attach form, where you select the file(s) and it automatically uploads them to the server. I''m pretty sure it involves an FTP server, which I know how to configure. It will be driven by PHP. I''m basically wondering how to make the form automatically upload the file to the server when the user clicks upload, without the user having to FTP in. Any ideas? http://roninmagus.hopto.org acronymfinder.com - Find any acronym you need!

Share this post


Link to post
Share on other sites
Advertisement
Im not sure about php but it was pretty easy to implement with java serlvets. www.oreillynet.com has a java library for doing such a thing. I was in a similiar situation as yourself a year ago and this worked great.

Im sure theres a way in php but just incase you get really stuck... this will work. Good luck.

ratman

Share this post


Link to post
Share on other sites
It''s not FTP. The standard way involves doing a HTTP POST with a content-type of ''multipart/form-data''. Your html forms stay the same, except you need to add an extra attribute to the form tag: enctype="multipart/form-data". What this does is tells the browser to send the post data as a multipart mime message instead of the standard url-encoded format.

Now, on the server side you usually need something to parse the incoming mime data back out into your parameters and file data. I don''t use PHP, but most servers don''t nativly support this. In Java I have my own code that does this, and in ASP I use a tool called SA-FileUp. I suggest searching for a tool that does this for you as writing one is kind of a hassle.

Hope this helps.

Share this post


Link to post
Share on other sites
This is really easy to do with PHP.

You just need a form that looks something like this:

      
<?
if ($submitted)
{
copy($_FILES['userfile']['tmp_name'], "/place/to/put/uploaded/file");
}
else
{
?>
<form enctype="multipart/form-data" method="post">
<input type="hidden" name="submitted" value="1">
Send this file: <input name="userfile" type="file">
<input type="submit" value="Send File">
</form>
<?
}
?>


Depending on what version of PHP you are using you might have to use $HTTP_POST_FILES or $HTTP_POST_VARS instead of $_FILES.
You can view a much better description of handling file uploads here:
PHP net explanation of file uploads

Hope that helps

[edited by - IcelandicSage on December 4, 2002 6:19:35 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!