0

$name = $_FILES['myfile'] ['name'];
$tmp_name = $_FILES ['myfile'] ['tmp_name'];

i wont to know why the variable $name, is begin with name
can somebody explain me this variables and parameters.

2
Contributors
5
Replies
8
Views
4 Years
Discussion Span
Last Post by andyy121
1

$name = $_FILES['myfile'] ['name']; will assign new name to the uploaded file. where $tmp_name = $_FILES ['myfile'] ['tmp_name']; will get the temp name of the uploaded file.

Suppose if you upload a file the system will automatically uploaded it to temp folder and it will assign some random code. That name you will get via $_FILES['myfile']['tmp_name'];

If you want to assign a new name for the uploaded file you can try

$_FILES['myfile']['name'] = date("YmdHms");
// Here it will assign timestamp to the new name
move_uploaded_file($_FILES['myfile']['tmp_name'], "uploads/".$_FILES['myfile']['name']);
// It will move the temporary uploaded file with new name i.e timestamp to the uploaded folder.
0

y are so kind. thnx

Edited by Ezzaral: Do not write in all uppercase or use "leet", "txt" or "chatroom" speak .

1

@Andyy121 Sharing knowledge is very important dude. Yah they are just for the names

$name = $_FILES['myfile'] ['name'];
$tmp_name = $_FILES ['myfile'] ['tmp_name'];

Where as $name and $tmp_name are the variables.

You can use any name
ex:-

$original_name = $_FILES['myfile']['name'];
$temp_name = $_FILES['myfile']['tmp_name'];

Edited by rayidi

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.