0

I want to save directory root value of file to database.

ex: I have file with directory c:\xampp\htdocs\myproject\app\views\index.php , but i just want get myproject\app\views\index.php. I want to get value from the input type file, is it possible ?

This is how proccess I want to build, but the value not like I want.

not like what i want

i want when user click choose file in <input type='file' />, i want default directory open in "myproject" . it's not about uploading file, i just want make validation from directory root value. in some case i have 2 file with same name "index.php", but one of file located in myproject\view\dir1\index.php and another one in myproject\view\dir2\index.php. so that sets it apart is the root directory.

thanks for help me.

randawahyup
  • 389
  • 2
  • 5
  • 15

2 Answers2

2

You can use the follwing:

\Yii::$app->basePath will give like D:\xampp\htdocs\advanced\backend

\Yii::$app->request->BaseUrl will give like localhost\advanced\backend\web\

You may store the image using \Yii::$app->basePath and show it using \Yii::$app->request->BaseUrl

Hope it helps

Chinmay Waghmare
  • 5,368
  • 2
  • 43
  • 68
  • @chinmay i want user choose file, and show directory root file from "myproject" not c:\xampp\htdocs\myproject , is it possible ? and when click choose file in ", i want default directory open in "myproject" . it's not about uploading file, i just want make validation from directory root value. in some case i have 2 file with same name "index.php", but one of file located in myproject\view\dir1\index.php and another one in myproject\view\dir2\index.php . – randawahyup Mar 25 '15 at 06:18
  • Sorry I didn't understand. Could you please update your question accordingly – Chinmay Waghmare Mar 25 '15 at 06:23
  • @chinmay there another problem my picture, can you look value in object name column ? it's actually c:\xampp\htdocs\myproject\views\dir1\index.php, not C:\fakepath\index.php – randawahyup Mar 25 '15 at 06:43
  • So the question is? Which path do you want there? – Chinmay Waghmare Mar 25 '15 at 06:46
  • how to get value of , and custom the value ? – randawahyup Mar 25 '15 at 06:59
  • Sorry dude not getting you. Can you post it as the new question. And if you find my answer helpful you can mark it as accepted :) – Chinmay Waghmare Mar 25 '15 at 07:18
  • yes i want custom value of . i'll using that value for validation form. hehe – randawahyup Apr 27 '15 at 02:06
  • i have new question about clean url in yii2 , may you can help me :) http://stackoverflow.com/questions/29885970/how-to-remove-url-web-index-php-yii-2-and-set-route-with-parameter-with-clean – randawahyup Apr 27 '15 at 02:08
  • I would be more than happy to help you. You can check the answer :) – Chinmay Waghmare Apr 27 '15 at 06:41
0

Please google the followings. Also search in stackoverflow

$_SERVER['DOCUMENT_ROOT'] dirname(__FILE__);
Parangan
  • 148
  • 1
  • 15