Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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".
file one gives a browse button that works and produces the correct name
the file I click ---   C:\thisdir\thisfile.pdf

2 - I click on the submit button (called pdfSource).  In my code I have
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
so I did a little strtok and turned it into
but that didn't work either so I changed it to
and that didn't work.

Can anyone help?


Re: Upload

sheldonlg@gmail.com wrote:
Quoted text here. Click to load it

Try using this instead:

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


Re: Upload

Quoted text here. Click to load it

Of course it should be:

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


Re: Upload

Quoted text here. Click to load it

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,  

Re: Upload

Quoted text here. Click to load it

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/features.file-upload.errors.php

"En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirvi
spam@outolempi.net | Gedoon-S @ IRCnet | rot13(xvzzb@bhgbyrzcv.arg)  

Re: Upload

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.

Re: Upload

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.

Site Timeline