I'm creating a website using symfony for blogging. Users can upload their posts to the site. when a user add a file it will save inside web/upload/file_upload
and the file path will save in add_post
table. When a admin view a add_post
table template he can see the path of the downloaded file of each and every user, what i want to do is through this file path download the file.
How can i do this?
edit 1:
Model - Blog_user Module - post
Table Structre - table name- Blog_user
1 user_id bigint(20)
2 gender varchar(255)
3 blog_status tinyint(1)
4 file varchar(255)
Form
'user_id' => new sfWidgetFormInputHidden(),
'gender' => new sfWidgetFormInputText(),
'file' => new sfWidgetFormInputFile(),
Here when uploading a file, the filepath save in Blog_user table and file save inside web/upload directory.
edit 2:
//save file method
public function saveFile(){
$file = $this->getValue('file');
if(isset($file)){
$filename = 'POST_Uploaded -' .($file->getOriginalName());
$file->save(sfConfig::get('sf_upload_dir').'/post_upload'.'/'.$filename);
}
}
E:\xampp\htdocs\trunk\web\uploads\post_upload\POSt_Uploaded -JS.pdf
This how it saved in side web/upload/post_upload directory and same path will save inside db also
edit 3:
when a user upload a blog it will save in blog_user table and it consist blog _id as primary key, user_id is on user table. what i want do is when user upload a file , both user_id , and blog_id should be saved inside blog table . how to do it?
user table - user_id , file(uploaded file)
blog table - blog_id - there are blog titles , each title has an unique blog id , so that user can upload a file under each titles,
post table - post_id, blog_id, user_id