By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,626 Members | 1,750 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,626 IT Pros & Developers. It's quick & easy.

Moving client fiile to server

P: n/a
Don
I'm trying to setup Javascript running in a browser window that, via
<input type="file"...>, will pickup a client file and then transfer it
to my space on the internet host I use. How do I go about doing
this?

Thanks,
Don
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 23 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
"Don" <no@adr.com> skrev i meddelandet
news:ac********************************@4ax.com...
I'm trying to setup Javascript running in a browser window that, via
<input type="file"...>, will pickup a client file and then transfer it
to my space on the internet host I use. How do I go about doing
this?


You submit the form like any other form. Server-side, you write a few lines
of script in your environment of choice that get called by the server when
the upload is completed. The path to the uploaded file will be provided by
the script environment. At least that's how it works with PHP.

Joakim Braun
Jul 23 '05 #2

P: n/a
Don
Thanks. But, can you show me some sample code. I'm having a lot of
trouble with this, and haven't done a whole lot of script coding.

Thanks, Don
On Mon, 6 Sep 2004 08:42:40 +0200, "Joakim Braun"
<jo**********@jfbraun.removethis.com> wrote:
"Don" <no@adr.com> skrev i meddelandet
news:ac********************************@4ax.com.. .
I'm trying to setup Javascript running in a browser window that, via
<input type="file"...>, will pickup a client file and then transfer it
to my space on the internet host I use. How do I go about doing
this?


You submit the form like any other form. Server-side, you write a few lines
of script in your environment of choice that get called by the server when
the upload is completed. The path to the uploaded file will be provided by
the script environment. At least that's how it works with PHP.

Joakim Braun


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 23 '05 #3

P: n/a
On Mon, 06 Sep 2004 00:07:26 -0700, Don <no@adr.com> wrote:
Thanks. But, can you show me some sample code. I'm having a lot of
trouble with this, and haven't done a whole lot of script coding.


This isn't a Javascript question, so I'm afraid it's not appropriate for
this group. You'll need to find out what server-side languages your host
supports and go to the relevant newsgroup. I expect you'll be able to
Google for the code, too.

[snip]

Good luck,
Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #4

P: n/a
Don
Thanks guys.
Don
On Sun, 05 Sep 2004 23:09:55 -0700, Don <no@adr.com> wrote:
I'm trying to setup Javascript running in a browser window that, via
<input type="file"...>, will pickup a client file and then transfer it
to my space on the internet host I use. How do I go about doing
this?

Thanks,
Don
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 23 '05 #5

P: n/a
"Don" <no@adr.com> skrev i meddelandet
news:43********************************@4ax.com...
Thanks. But, can you show me some sample code. I'm having a lot of
trouble with this, and haven't done a whole lot of script coding.

Thanks, Don


From the "Handling file uploads" section of the PHP manual (www.php.net).

<?php
$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir . $_FILES['userfile']['name'];

print "<pre>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
print "File is valid, and was successfully uploaded. ";
print "Here's some more debugging info:\n";
print_r($_FILES);
} else {
print "Possible file upload attack! Here's some debugging info:\n";
print_r($_FILES);
}
print "</pre>";

?>

This is the server-side PHP code stored in (for instance) a page that is the
file upload form's action.

Joakim Braun
Jul 23 '05 #6

P: n/a
Joakim Braun spilled the following:
"Don" <no@adr.com> skrev i meddelandet
news:ac********************************@4ax.com...
I'm trying to setup Javascript running in a browser window that, via
<input type="file"...>, will pickup a client file and then transfer it
to my space on the internet host I use. How do I go about doing
this?


You submit the form like any other form. Server-side, you write a few
lines of script in your environment of choice that get called by the
server when the upload is completed. The path to the uploaded file will be
provided by the script environment. At least that's how it works with PHP.


One thing to watch out for is that you must specify the encoding type for
the form (which I always forget):

<form enctype="multipart/form-data" action="somescript.php" method="post">
....

HTH

C.
Jul 23 '05 #7

P: n/a
Don
Thanks everyone. I really appreciate your help.
Don
On Sun, 05 Sep 2004 23:09:55 -0700, Don <no@adr.com> wrote:
I'm trying to setup Javascript running in a browser window that, via
<input type="file"...>, will pickup a client file and then transfer it
to my space on the internet host I use. How do I go about doing
this?

Thanks,
Don
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 23 '05 #8

P: n/a
Don
On Mon, 6 Sep 2004 23:09:09 +0200, "Joakim Braun"
<jo**********@jfbraun.removethis.com> wrote:
"Don" <no@adr.com> skrev i meddelandet
news:43********************************@4ax.com.. .
Thanks. But, can you show me some sample code. I'm having a lot of
trouble with this, and haven't done a whole lot of script coding.

Thanks, Don


From the "Handling file uploads" section of the PHP manual (www.php.net).

<?php
$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir . $_FILES['userfile']['name'];

print "<pre>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
print "File is valid, and was successfully uploaded. ";
print "Here's some more debugging info:\n";
print_r($_FILES);
} else {
print "Possible file upload attack! Here's some debugging info:\n";
print_r($_FILES);
}
print "</pre>";

?>

This is the server-side PHP code stored in (for instance) a page that is the
file upload form's action.

Joakim Braun

Thanks, this is just what I am looking for. Appreciate your help.
Don
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 23 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.