Access variable outside of Excel::load in Laravel - php

I would like to ask if how can I access the error message variable when I execute the a foreach loop inside the Excel::load function which reads the csv file that I uploaded so that I can return it via the Response::json();
Here's my code:
$errorMessage['error'] = [];
if($request->hasFile('file')){
if($request->file('file')->getClientOriginalExtension() != "csv"){
$errorMessage['error'][] = "File should be in csv format";
}
else {
$fileName = $request->file('file')->getClientOriginalName().".csv";
$destination = base_path().'/storage/excel/imports';
$request->file('file')->move($destination, $fileName);
$csvFile = base_path().'/storage/excel/imports/'.$fileName;
$demographics = $request->get('demographics');
\Excel::load($csvFile, function($reader) use($demographics,$errorMessage) {
if($demographics == "region"){
foreach($reader->get()->toArray() as $data){
$region = Region::whereRaw("LCASE(`short_name`) = ?", array(strtolower($data['region_name'])))->first();
if($region){
$regionData = Region::find($region->id);
$regionData->total_number_of_provinces = $data['total_provinces'];
$regionData->total_number_of_cities_municipalities = $data['total_cities_and_municipalities'];
$regionData->save();
}
else {
$errorMessage['error'][] = $data['region_name'] . " is not existing in the database";
}
}
}
});
}
}
else {
$errorMessage['error'][] = "Please specify a file";
}
return \Response::json($errorMessage);

Bit smelly, but you can declare it a class property.
/**
* #var array
*/
protected $errorMessage;
public function doStuff()
{
// ...
\Excel::load($file, function($reader) use ($demographics) {
// ...
$this->errormessage['error'][] = $data['region_name'];
});
// ...
return \Response::json($this->errorMessage);
}
Note
You can also pass $errorMessage by reference, which a lot of people think is the better choice (you're using a throw-away function after all).
\Excel::load($file, function($reader) use ($demographics, &$errorMessage)
I don't like to do this however, because in my opinion it's less readable what I meant to do. You can choose one of either picks though!
Useful and short explanation: http://culttt.com/2013/03/25/what-are-php-lambdas-and-closures/

$fileName = md5(time()) .'.'.$request->file('file')->getClientOriginalExtension();
$sheet_id = $request->session()->get('sheet_id');
$excel=Excel::load(public_path('/uploads/importsheet/'.$fileName),function ($reader)use ($sheet_id) {
$reader->each(function($sheet) use ($sheet_id) {
$headings = $sheet->keys()->toArray();
for($i=0; $i<count($headings); $i++){
$sheet_id = DB::table('import_sheets_attributes')->insertGetId(
[
'import_sheets_id' => $sheet_id,
'attribute' => $headings[$i],
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s')
]);
}
});
});
Hope the above sample code will help.

Related

Problem of Curly Brackets in my controller Php Symfony

I want to call my function but when I call it I have a problem with curly Brackets at the end of my code and i have this error Error SYMFONY ( {} ) in my Controller.
I have no idea where to put them for my code to work. I have this problem when I add my function that allows me to retrieve the
history of the action. The mentioned function goes as this:
$this->logHistory->addHistoryConnection($project->getId(), $user->getId(), 'Delete Local Suf', $sf_code);
Function Supp Suf
/**
* #Route("/creation/suf/supp", name="suf_supp")
*/
public function suf(
Request $request,
ShapesRepository $shapesRepository
) {
$params = $this->requestStack->getSession();
$projet = $params->get('projet');
$modules = $params->get('modules');
$fonctionnalites = $params->get('fonctionnalites');
$user = $this->getUser()->getUserEntity();
$manager = $this->graceManager;
$mapManager = $this->mapManager;
$countElements = $mapManager->getCount();
$shapes = $shapesRepository->findBy(array('projet' => $projet->getId()));
$adresseWeb = $this->getParameter('adresse_web');
$carto = $params->get('paramCarto');
$centrage = $params->get('centrage');
$cableColor = $params->get('cableColor');
$sf_code = '';
if ($request->get('suf') != '') {
$sf_code = $request->get('suf');
}
$suf = $manager->getSuf($sf_code);
$success = '';
$error = '';
$warning = '';
if ($request->query->get('success')) {
$success = $request->query->get('success');
} elseif ($request->query->get('error')) {
$error = $request->query->get('error');
} elseif ($request->query->get('warning')) {
$warning = $request->query->get('warning');
}
if ($request->isMethod('POST')) {
if ($request->request->get('sf_code') != '') {
$sf_code = $request->request->get('sf_code');
}
if ($request->get('val') != '') {
$val = $request->get('val');
}
$dir = $this->getparameter('client_directory');
$dossier = str_replace(' ', '_', $projet->getProjet());
$dir = $dir . $dossier . '/documents/';
$cable = $val[0];
$chem = $val[1];
$t_suf = $this->graceCreator->supprimeSuf($sf_code, $cable, $chem);
if ($t_suf[0][0] == '00000') {
$this->logHistorique->addHistoryConnection($projet->getId(), $user->getId(), 'Suppression Suf Local', $sf_code);
// $creator->delDirObjet( $st_code, $dir );
$data = new JsonResponse(array("success" => "create!"));
return $data;
} else {
$data = new JsonResponse(array("error" => "Error : " . $t_suf));
return $data;
}
return $this->render('Modifications/supSuf.html.twig', array(
'user' => $user,
'paramCarto' => $carto,
'cableColor' => $cableColor,
'suf' => $suf,
'adresseWeb' => $adresseWeb,
'centrage' => $centrage,
'shapes' => $shapes,
'projet' => $projet,
'modules' => $modules,
'fonctionnalites' => $fonctionnalites,
'countElements' => $countElements
));
}
}
Your only return statement is inside of an if condition. If the code does not pass the condition, it has nothing to return. The code must return something in all possible cases. If you are not still used to these practices, an IDE might guide you until it becomes a routine. PHPStorm is my personal preference.
BTW, I recommend you to switch from the array() syntax to the more globally accepted [] although you must be in PHP 5.4 or higher.

File not found at path: on laravel 5.6

i am using laravel 5.6, i will try to make function multiple upload video, and get frame and duration with laravel-ffmpeg, but when i try to upload one video for example, always show error like "File not found at path:",
this is my function to store video and get duration & frame :
public function doCreate($lessonsid)
{
if (empty(Session::get('contribID'))) {
return redirect('contributor/login');
}
# code...
// validate
// read more on validation at http://laravel.com/docs/validation
$rules = array(
'judul' => 'required',
// 'video.*' => 'mimes:mp4,mov,ogg,webm |required|max:100000',
// 'image.*' => 'mimes:jpeg,jpg,png,gif|required|max:30000'
);
$validator = Validator::make(Input::all(), $rules);
// process the login
if ($validator->fails()) {
return redirect()->back()->withErrors($validator)->withInput();
} else {
$now = new DateTime();
$cid = Session::get('contribID');
$title = Input::get('judul');
$image_video = Input::file('image');
$lessons_video = Input::file('video');
// dd($lessons_video);
// $media = FFMpeg::open('https:/dev.cilsy.id/assets/source/lessons/lessons-74/video-8/1. Introduction (2).mp4');
// $frame = $media->getFrameFromString('00:00:13.37');
// dd($media);
$description = Input::get('desc');
$video=Video::where('lessons_id',$lessonsid)->get();
$count_video=count($video);
if (!is_dir("assets/source/lessons/lessons-$lessonsid")) {
$newforder=mkdir("assets/source/lessons/lessons-".$lessonsid);
}
$i=$count_video + 1;
foreach ($title as $key => $titles) {
$type_video =$lessons_video[$key]->getMimeType();
if (!is_dir("assets/source/lessons/lessons-".$lessonsid."/video-".$i)) {
$newforder=mkdir("assets/source/lessons/lessons-".$lessonsid."/video-".$i);
}
$DestinationPath= 'assets/source/lessons/lessons-'.$lessonsid.'/video-'.$i;
//insert image
if(!empty($image_video[$key])){
$imagefilename = $image_video[$key]->getClientOriginalName();
$image_video[$key]->move($DestinationPath, $imagefilename);
}else{
$imagefilename = '';
}
if($imagefilename ==''){
$url_image= $imagefilename;
}else{
$urls=url('');
$url_image= $urls.'/assets/source/lessons/video-'.$i.'/'.$imagefilename;
}
//insert video
if(!empty($lessons_video[$key])){
$lessonsfilename = $lessons_video[$key]->getClientOriginalName();
$lessons_video[$key]->storeAs($DestinationPath, $lessonsfilename);
}else{
$lessonsfilename = '';
}
if($lessonsfilename ==''){
$url_video= $lessonsfilename;
}else{
$urls=url('');
$url_video= $urls.'/assets/source/lessons/video-'.$i.'/'.$lessonsfilename;
}
$store = new Video;
$store->lessons_id = $lessonsid;
$store->title = $titles;
$store->image = $url_image;
$store->video = $url_video;
$store->description = $description[$key];
$store->type_video = $type_video;
$store->durasi = 0;
$store->created_at = $now;
$store->enable=1;
$store->save();
if($store){
$media = FFMpeg::open($url_video);
// $frame = FFMpeg::open($link)
// ->getFrameFromSeconds(10)
// ->export()
// ->toDisk('public')
// ->save($filename.'.png');
dd($media);
$durationInSeconds = $media->getDurationInSeconds();
// dd($media);
}
$i++;
}
// Session::set('lessons_title',$title);
// Session::set('lessons_category_id',$category_id);
// Session::set('lessons_image',$image);
// Session::set('lessons_description',$description);
return redirect('contributor/lessons/'.$lessonsid.'/view')->with('success','Penambahan video berhasil');
}
}
this is message error, when i try to upload my video
anyone can help me?
try with public_path()
$DestinationPath= public_path().'/'.'assets/source/lessons/lessons-'.$lessonsid.'/video-'.$i;
You files are not saving, you should use public_path helper for storing and retrieving files back.
$image_video[$key]->move(public_path('lessons/lessons-'.$lessonsid.'/video-'.$i), $imagefilename);
Or you can store them into storage folder
$image_video[$key]->move(storage_path('lessons/lessons-'.$lessonsid.'/video-'.$i), $imagefilename);
You can retrieve back files using these helpers.
Hope this helps.

How to differentiate filename without hardcoding it?

i have a config like so :
$CONF['log']['TSEL_MV_GW_SERV101_MT_CONNECTOR_STATUS'] = array(
'folder' => $CONF['mainFolder']."/log_sample/tsel",
'files' => array(
'connector_access_log*.log',
'engine_dr_to_app_hit_dr_url*.log'
)
);
then i'm getting all the files with that pattern that has today date.
foreach($CONF['log'] as $label => $arrayData){
$filePaths = array();
$today = date("Ymd", time());
foreach($arrayData['files'] as $filePrefix){
$glob = glob($arrayData['folder']."/".$filePrefix, GLOB_ERR);
if(count($glob) >= 1){
foreach($glob as $file){
if(strpos($file, $today)){
$filePaths[] = $file;
}
}
}
}
}
$filePaths array content :
Array
(
[0] =>/dirpath/connector_access_log_20171025.log
[1] =>/dirpath/engine_dr_to_app_hit_dr_url_20171025.log
)
Now, i need to process each file differently, how can i do this using foreach loop ?
using hardcode such as if(preg_match("connector_access_log")) is not allowed.
this is my approach before :
foreach($filePaths as $filePath){
if(preg_match("/connector_access_log_/", $filePath, $match)){
#some code
} else if (preg_match("/engine_dr_to_app_hit_dr_url_/", $filePath, $match)){
#some code
}
}
What you could do is, you could tweak the configuration to store files in assosiative array Eg.
$CONNECTOR_ACCESS_LOG = 'connector_access_log'
$ENGINE_URL_LOG = 'engine_dr_to_app_hit_dr_url'
$CONF['log']['TSEL_MV_GW_SERV101_MT_CONNECTOR_STATUS'] = array(
'folder' => $CONF['mainFolder']."/log_sample/tsel",
'files' => array(
$CONNECTOR_ACCESS_LOG => 'connector_access_log*.log',
$ENGINE_URL_LOG => 'engine_dr_to_app_hit_dr_url*.log'
)
);
And then in the loop you can get these keys and switch case between them. Eg.
foreach($CONF['log'] as $label => $arrayData){
$today = date("Ymd", time());
foreach($arrayData['files'] as $filetype => $filePrefix){
$glob = glob($arrayData['folder']."/".$filePrefix, GLOB_ERR);
if(count($glob) >= 1){
foreach($glob as $file){
if(strpos($file, $today)){
switch($filetype) {
case $CONNECTOR_ACCESS_LOG: doConnection($file); break;
case $ENGINE_URL_LOG : doEngine($file); break;
}
}
}
}
}
}
Please pardon my php syntax, i am just trying to give an idea.
If you really don't want to use a hardcode you should pass a handler for each file type through your config. Like mostly frameworks do. Please see yii2 logger for more examples. Here is a piece of pseudocode:
$CONF['log']['TSEL_MV_GW_SERV101_MT_CONNECTOR_STATUS'] = array(
new FirstLogger($CONF['mainFolder']."/log_sample/tsel", 'connector_access_log*.log'),
new SecondLogger($CONF['mainFolder']."/log_sample/tsel", 'engine_dr_to_app_hit_dr_url*.log'),
);
Next, proccess your log files by your handler in your handler class.
class FirstLogger
{
protected $dir = null;
protected $fileWildCard = null;
public function __construct($dir, $fileWildcard)
{
$this->dir = $dir;
$this->fileWildCard = $fileWildcard;
}
public function getFiles()
{
$filePaths = [];
$today = date("Ymd", time());
$glob = glob($this->dir."/".$this->fileWildCard, GLOB_ERR);
if(count($glob) >= 1){
foreach($glob as $file){
if(strpos($file, $today)){
$filePaths[] = $file;
}
}
}
return $filePaths;
}
public function handleLogs()
{
$files = $this->getFiles();
//some of your logic
}
}
Next, you probably want to create an interface for all of your loggers and an abstract class from which your loggers will be inherited.

Why is my app running out of memory? Unsetting variables, using chunk

I have the simple app below. I'm turning off query logging in Laravel, I'm unsetting where possible, yet this function will only process about 800 records before I'm out of RAM on my 2GB Linode. I know I'm asking a lot of you guys but I can't seem to see where I'm leaking memory.
There are really only two major steps.
Step 1 - Move records from a temp table to production
class ListingMigrator
{
public function __construct($tempListing, $feed)
{
$this->tempListing = $tempListing;
$this->listing = $this->listingInstance();
$this->feed = $feed;
}
public static function migrateListing($listing, $feed)
{
$instance = new static($listing, $feed);
return $instance->migrate();
}
public function migrate()
{
$this->addExternalData();
$this->populateListing();
$this->processPhotos();
$this->deleteTempListing();
}
private function listingInstance()
{
DB::connection()->disableQueryLog();
$listing = Listing::findByMud($this->tempListing->matrix_unique_id);
return $listing ?: new Listing;
}
private function processPhotos()
{
$retsApi = new RetsFeedApi($this->feed);
/* Initialize Object */
$rets = $retsApi->findMostRecent();
$photos = $rets->getPhotosForListing($this->listing->matrix_unique_id);
foreach ($photos as $photo)
{
$uploader = new PhotoProcessor($this->listing, $photo);
$uploader->process();
}
}
private function populateListing()
{
DB::connection()->disableQueryLog();
$this->listing->fill($this->tempListing->toArray());
$this->listing->imported_at = $this->tempListing->created_at;
$this->listing->board = $this->tempListing->board;
return $this->listing->save();
}
private function addExternalData()
{
// Get Google lattitude and longitude
$googlecoords = getGoogleMapInfo($this->tempListing->FullAddress, $this->tempListing->City);
$this->listing->GoogleLat = $googlecoords['GoogleLat'];
$this->listing->GoogleLong = $googlecoords['GoogleLong'];
// Add or update the Subdivision Table (helper function)
$subdivisiondata = SubdivisionUpdate($this->tempListing->board, $this->tempListing->SubCondoName, $this->tempListing->Development);
$this->listing->SubdivisionID = $subdivisiondata['id'];
}
private function deleteTempListing()
{
return $this->tempListing->delete();
}
}
Step 2 - Download photos and reupload to Amazon S3
class PhotoProcessor
{
public function __construct(Listing $listing, $photoData)
{
$this->bucket = 'real-estate-listings';
$this->s3 = App::make('aws')->get('s3');
$this->tempFileName = 'app/storage/processing/images/retsphotoupload';
$this->photoData = $photoData;
$this->listing = $listing;
$this->photo = new RetsPhoto;
}
public function process()
{
$this->storeTempFile();
$this->storeFileInfo();
$this->buildPhoto();
$success = $this->pushToS3();
// if Result has the full URL or you want to build it, add it to $this->photo
DB::connection()->disableQueryLog();
$this->listing->photos()->save($this->photo);
$this->removeTempFile();
unset ($this->photoData);
return $success;
}
private function storeTempFile()
{
return File::put($this->tempFileName, $this->photoData['Data']) > 0;
}
private function storeFileInfo()
{
$fileInfo = getimagesize($this->tempFileName);
// Could even be its own object
$this->fileInfo = [
'width' => $fileInfo[0],
'height' => $fileInfo[1],
'mimetype' => $fileInfo['mime'],
'extension' => $this->getFileExtension($fileInfo['mime'])
];
}
private function buildPhoto()
{
$this->photo->number = $this->photoData['Object-ID']; // Storing this because it is relevant order wise
$this->photo->width = $this->fileInfo['width'];
$this->photo->height = $this->fileInfo['height'];
$this->photo->path = $this->getFilePath();
}
private function getFilePath()
{
$path = [];
if ($this->listing->City == NULL)
{
$path[] = Str::slug('No City');
}
else
{
$path[] = Str::slug($this->listing->City, $separator = '-');
}
if ($this->listing->Development == NULL)
{
$path[] = Str::slug('No Development');
}
else
{
$path[] = Str::slug($this->listing->Development, $separator = '-');
}
if ($this->listing->Subdivision == NULL)
{
$pathp[] = Str::slug('No Subdivision');
}
else
{
$path[] = Str::slug($this->listing->Subdivision, $separator = '-');
}
if ($this->listing->MLSNumber == NULL)
{
$pathp[] = Str::slug('No MLSNumber');
}
else
{
$path[] = Str::slug($this->listing->MLSNumber, $separator = '-');
}
$path[] = $this->photoData['Object-ID'].'.'.$this->fileInfo['extension'];
return strtolower(join('/', $path));
}
private function pushToS3()
{
return $this->s3->putObject([
'Bucket' => $this->bucket,
'Key' => $this->photo->path,
'ContentType'=> $this->fileInfo['mimetype'],
'SourceFile' => $this->tempFileName
]);
}
private function getFileExtension($mime)
{
// Use better algorithm than this
$ext = str_replace('image/', '', $mime);
return $ext == 'jpeg' ? 'jpg' : $ext;
}
private function removeTempFile()
{
return File::delete($this->tempFileName);
}
}
Edit to show RetsPhoto
class RetsPhoto extends Eloquent {
protected $table = 'rets_property_photos';
public function listing() {
return $this->belongsTo('Listing', 'matrix_unique_id', 'matrix_unique_id');
}
}
Edit #2: Chunk Call
This is in the app/command and the only thing in there is the fire() function below:
public function fire()
{
// Turn off query logging
DB::connection()->disableQueryLog();
$feeds = RetsFeed::where('active','=',1)->get();
foreach ($feeds as $feed)
{
$class = "TempListing{$feed->board}";
$listings = $class::orderBy('MatrixModifiedDT','desc');
$listings->chunk(50, function($listings) use($feed) {
$listings->each(function($listing) use ($feed) {
ListingMigrator::migrateListing($listing,$feed);
echo "Feed: $feed->board\r\n";
echo "SubcondoName: $listing->SubCondoName\r\n";
echo "Development: $listing->Development\r\n";
echo "\r\n";
});
});
}
}
I think I have figured it out.
Your system holds in memory all of the photo data. As witnessed by the unset ($this->photoData);
The problem is that you need to first complete the process function. Your application is not likely processing ANY photos so when you keep grabbing them from the file system you run out of memory BEFORE you even process a single one.
To Confirm this, simply grab 1 file not using the chunk method.
I am not very familar with Laravel, it could be grabbing all of the files all at once as well and eating the ram.
You can do some tracing with memory_get_usage(true) to find out exactly where the ram is getting eaten from. I would suggest analysing the fire method first.

Codeigniter if id = 1 it works multiple image update but id =2 it's not working

My codes multiple image upload and update mysql db but one problem if id=1 It's working multiple image uploading and update.else It's not working and white page.
tables 2
musteri_soru and musteri_cevap
is updating musteri_cevap in colon resim
controller code:
function duzenle($no)
{
if($_POST)
{
$arr1['baslik'] = $this->input->post('soru');
$this->form_duzenle_model->duzenle($no,$arr1);
if($_FILES){
$dizin= "../upload/form_cevap/";
$dosya_sayi=count($_FILES['cevap']['name']);
for($i=0;$i<=$dosya_sayi;$i++){
$isim= md5(uniqid(rand()));
if(!empty($_FILES['cevap']['name'][$i])){
move_uploaded_file($_FILES['cevap']['tmp_name'][$i],"./$dizin/$isim{$_FILES['cevap']['name'][$i]}");
$arr['resim']= $dizin.$isim.$_FILES['cevap']['name'][$i];
}
$approve[] = $arr['resim'];
$it = $approve;
print_r($approve);
foreach($it as $n => $c):
/* $deneme = $this->form_duzenle_model->cevapDuzenle($n,$c); */
endforeach;
}
}
redirect('form_duzenle/', 'refresh');
}else{
$this->bc->addCrumb('Düzenle');
$veri = $this->form_duzenle_model->form_duzenleGetir($no)->row();
$veri2 = $this->form_duzenle_model->cevapListe($no)->result();
$data = array(
'baslik'=>$veri->baslik,
'veri' =>$veri,
'cevap' =>$veri2
);
$this->bc->addCrumb($veri->baslik,'form_duzenle/duzenle/'.$veri->no);
$this->layout->view('form_duzenle/form_duzenle_duzenle',$data);
}
}
Models code :
function duzenle($no,$data)
{
$this->db->update($this->tablo,$data, array('no' => $no));
}
function cevapDuzenle($n,$dat)
{
$data = array('resim' => $dat);
$this->db->update($this->ctablo,$data, array('soru_no' => $n));
}
My Tables
enter link description here
To be honest, I'm not quite sure how your upload was working as the $_FILES array shouldn't be nesting the uploads in the way you've shown above.
I'm not saying this will definitely work but it should do:
function duzenle($no)
{
//I would possible look at using the Form_validation Library here
if (empty($_POST)) {
$arr1['baslik'] = $this->input->post('soru');
$this->form_duzenle_model->duzenle($no, $arr1);
if (!empty($_FILES)) {
$dizin = "../upload/form_cevap/";
foreach ($_FILES as $name => $file) {
//If there is an error there isn't any reason to try and upload this file
if ($file['error'] !== 0) {
continue;
}
$name = $file['name'];
$isim = md5(uniqid(rand()));
move_uploaded_file($file['tmp_name'], "./$dizin/$isim$name");
$arr['resim'] = $dizin . $isim . $name;
//Not sure what's going on here so I haven't changed it
$approve[] = $arr['resim'];
$it = $approve;
print_r($approve);
foreach ($it as $n => $c):
/* $deneme = $this->form_duzenle_model->cevapDuzenle($n,$c); */
endforeach;
}
}
redirect('form_duzenle/', 'refresh');
}else {
$this->bc->addCrumb('Düzenle');
$veri = $this->form_duzenle_model->form_duzenleGetir($no)->row();
$veri2 = $this->form_duzenle_model->cevapListe($no)->result();
$data = array(
'baslik' => $veri->baslik,
'veri' => $veri,
'cevap' => $veri2
);
$this->bc->addCrumb($veri->baslik, 'form_duzenle/duzenle/' . $veri->no);
$this->layout->view('form_duzenle/form_duzenle_duzenle', $data);
}
}
Hope this helps!
Check your for loop,
$dosya_sayi=count($_FILES['cevap']['name']);
for($i=0;$i<=$dosya_sayi;$i++)
for loop condition should be $i < $dosya_sayi as array index always starts from 0.
So correct for loop is
for($i=0;$i<$dosya_sayi;$i++)
I solved the problem.Duzenle codes on change the bottom code.
function duzenle($no)
{
if($_POST)
{
$arr1['baslik'] = $this->input->post('soru');
$this->form_duzenle_model->duzenle($no,$arr1);
$cevaplar = $this->form_duzenle_model->cevapListe($no)->result_array();
if($_FILES){
$dizin= "../upload/form_cevap/";
foreach($cevaplar AS $cevap){
$i = $cevap['no'];
$isim= md5(uniqid(rand()));
if(!empty($_FILES['cevap']['name'][$i])){
move_uploaded_file($_FILES['cevap']['tmp_name'][$i],"./$dizin/$isim{$_FILES['cevap']['name'][$i]}");
$arr['resim']= $dizin.$isim.$_FILES['cevap']['name'][$i];
}
$approve[] = $arr['resim'];
$it = $approve;
$this->form_duzenle_model->cevapDuzenle($i,$arr['resim']);
}
}
redirect('form_duzenle/', 'refresh');
}else{
$this->bc->addCrumb('Düzenle');
$veri = $this->form_duzenle_model->form_duzenleGetir($no)->row();
$veri2 = $this->form_duzenle_model->cevapListe($no)->result();
$data = array(
'baslik'=>$veri->baslik,
'veri' =>$veri,
'cevap' =>$veri2
);
$this->bc->addCrumb($veri->baslik,'form_duzenle/duzenle/'.$veri->no);
$this->layout->view('form_duzenle/form_duzenle_duzenle',$data);
}
}

Categories