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

Upload

P: n/a
Ok, its been a while since I last wrote upload code and I am having a
problem. Here is what I have done:

1 - Two <input>s. One is type="file" and the other is type="submit".
The
file one gives a browse button that works and produces the correct name
of
the file I click --- C:\thisdir\thisfile.pdf

2 - I click on the submit button (called pdfSource). In my code I have
a
block with if isset($_POST['pdfSource']) amd it enters that block.

Here is where the fun begins.

In the previous code I had written, I simply had a
copy($_FILES['filename']['tmp_name'], "destination_on_server");

and it had worked.

Now, $_FILES['filename']['tmp_name'] and
$_FILES['filename']['tmp_name'] is
empty so it fails.

I then did:
$_FILES['filename']['tmp_name'] = $_POST['pdfSource'];

That didn't work because $_POST['pdfSource'] was
C:\\thisdir\\thisfile.pdf
so I did a little strtok and turned it into
C:\thisdir\thisfile.pdf
but that didn't work either so I changed it to
C:/thisdir/thisfile.pdf
and that didn't work.

Can anyone help?

Shelly

Feb 16 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
sh*******@gmail.com wrote:
[snip]
Here is where the fun begins.

In the previous code I had written, I simply had a
copy($_FILES['filename']['tmp_name'], "destination_on_server");

[snip]

Try using this instead:

move_uploaded_file($_FILES['userfile']['tmp_name'], "path/to/file.ext");

Zilla.
Feb 16 '06 #2

P: n/a
> move_uploaded_file($_FILES['userfile']['tmp_name'], "path/to/file.ext");

Of course it should be:

move_uploaded_file($_FILES['filename']['tmp_name'], "path/to/file.ext");

Zilla
Feb 16 '06 #3

P: n/a

"Zilla" <ma*********@an.option> wrote in message
news:43***********************@news.sunsite.dk...
move_uploaded_file($_FILES['userfile']['tmp_name'], "path/to/file.ext");


Of course it should be:

move_uploaded_file($_FILES['filename']['tmp_name'], "path/to/file.ext");

Zilla


The problems are that $_FILES['filename']['tmp_name'] comes up empty and if
I fill it with the right value the it still can't upload because it says
that the file isn't there,
Feb 16 '06 #4

P: n/a
"Shelly" <sh************@asap-consult.com> wrote in message
news:cX******************@bignews5.bellsouth.net.. .

"Zilla" <ma*********@an.option> wrote in message
news:43***********************@news.sunsite.dk...
move_uploaded_file($_FILES['userfile']['tmp_name'], "path/to/file.ext");


Of course it should be:

move_uploaded_file($_FILES['filename']['tmp_name'], "path/to/file.ext");

Zilla


The problems are that $_FILES['filename']['tmp_name'] comes up empty and
if I fill it with the right value the it still can't upload because it
says that the file isn't there,

Then you need to make sure the file does get uploaded! I'd recommend you put
this somewhere in the file and make sure you get 0 in it.
echo "file uploaded status: " . $_FILES['filename']['error'];

0 (zero) means ok, file uploaded with no errors. The other error codes are
explained here: http://fi2.php.net/manual/en/feature...oad.errors.php
--
"En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviö
sp**@outolempi.net | Gedoon-S @ IRCnet | rot13(xv***@bhgbyrzcv.arg)
Feb 16 '06 #5

P: n/a
Ok, it seems I am not making myself clear. Let me try again.
1 - I am not getting the upload.
2 - I am not trying to move a file that is already uploaded. It never
gets there.
3 - It doesn't get there because it says that the file is not on my
SOURCE system, even though using the browse button that comes with the
type="files" puts it in the text area when selected.
4 - The $_FILES['filename']['tmp_name'] and the
$_FILES['filename']['tmp_name'] come up empty for the SOURCE system
file when I hit the "Upload" button which is leads me to the block of
code which actually does the upload (and I get into that block of code
-- I tested it).
5 - If I do a $source = $_POST['sourcePDF'] it comes up with
double backslashes instead of the single backslashes that appear in the
text are for the type="files" input control. If I then set the $_FILES
variable to that one, it fails with "the file or directory cannot be
found" for the SOURCE system .
6 - If I do some strtok processing to turn those double backslashes
into single ones, it still cannot find the SOURCE system file.
7 - If I turn those double backslashes into forward slashes it still
cannot find the SOURCE system file.

When I had done this before, on the previous site that I had coded for
uploads, the $_FILES variable was somehow filled in with the proper
value (whatever that was), and uploaded the file. I then, later, moved
that file from the temporary holding area on the server system to a
permanent area on the server system.

Right now I cannot even find the file on the source system, even though
I select if with the Browse button provided.

Feb 16 '06 #6

P: n/a
As usual, it was SOE (Stupid operator error). I forgot to include
enctype="multipart/form-data" in the form declaration.

Thanks all as I slither away embarassed.

Feb 16 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.