0

Not sure if that was the best Title in the world but I hope this part gives you a clearer understanding of what my question is.

Basically I need to send a File using a Form to the folder "uploads" from page 1

I then go to page 2

I then need to then send the same file to the database from page 2

Is there a way on page 2 to define the Value as say Value="upload/"

?

I tried this way but it did not work.

How can I make the value a file which is in a folder in my server

Or is there another way to do is like past the file in a POST to the next page ?

1 Answer 1

1

Put the name of the file in a $_SESSION variable, say $_SESSION['curfile']='myfile.ext'; When processing the 2nd page, get the file name from the $_SESSION and store it in the database.

Sign up to request clarification or add additional context in comments.

4 Comments

Perfect :) Thanks a alot So would the session store the file? then all I do is make the variable the filename ? Then echo out the variable into the value ?
No, the file is stored in whatever directory you told it to be stored in. When you want to put in the db, you use the filename (with the directory you know you put it in) to copy it from where it is to the db. But really, it's better to just store the path to the file in the db and let the file live in a filesystem.
Sorry to be a pain but say if I stored it in uploads and the filename was called test01 how could I then place that file automatically into a form and upload it again ?
So when you process page1, you store the uploaded file as /uploads/test01. You put the string 'test01' in your $_SESSION. When you want to move the file somewhere else, you would either copy or move "/uploads/{$_SESSION['filename']}" to the desired directory. You do NOT need to "upload" the file twice because it is already on the server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.