PHP File Upload, using the FILES superglobal array

Posted by jnkrois on Stack Overflow See other posts from Stack Overflow or by jnkrois
Published on 2010-05-07T01:31:43Z Indexed on 2010/05/07 1:38 UTC
Read the original article Hit count: 241

Filed under:
|
|

Hello everybody, I just have a quick question.

Let's say that I'm setting up an upload feature for a project. I'm using PHP5, and I was wondering if by using the $_FILES superglobal array, I could have access to the "tmp_name" array key , which is the temporary path and name of the file being uploaded to display a preview of the image, before moving it to the "uploads" folder in the server.

What I had in mind is something like this: Use jQuery to detect when the "file" input filed changes (when the user selects an image file), then place an ajax call to upload the the file, which will move it to the temp folder even before I use "move_uploaded_file". If I can somehow access the "tmp_name" array key, I could probably put it into and "img" tag to display a preview. Later move the file to it's final location when the submit button is clicked.

I'm not asking for any code examples or anything, since I'd be thrilled to accomplish this on my own, I just want to find out if there is access to that array key in any way. Thanks in advance.

© Stack Overflow or respective owner

Related posts about php5

Related posts about file