mrestufp20's avatar

C:\xampp\tmp\phpCEC2.tmp (laravel) how to fix that ?

I can not send the file to the database, although it can be created but instead appears C: \ xampp \ tmp \ phpCEC2.tmp, and the file is not to send in my folder

this my Controller

namespace App\Http\Controllers;

use Illuminate\Http\Request; use App\Project; use App\User; use App\Adpro; use Illuminate\Support\Facades\Input; use DB; use Validator; use Session; use Redirect;

class IosController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */

 public function __construct()
{
    $this->middleware('auth');
}


public function search(Request $request){
    $cari = $request->get('search');
    $project = Project::where('ppj_id','LIKE','%'.$cari.'%')->paginate(5);
    return view('project.index', compact('project'));
}




public function index()
{
   //$project = DB::table('project')->paginate(5);
    
    $project = Project::all();
    return view('project.index', ['project' => $project]);
}

/**
 * Show the form for creating a new resource.
 *
 * @return \Illuminate\Http\Response
 */
public function create()
{
     $user = User::all();
     $adpro = Adpro::all();
     return view('project.create', compact(['user', $user], ['adpro', $adpro]));
}

/**
 * Store a newly created resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */
public function store(Request $request)
{
    
    $filename = Input::file('foto')->getClientOriginalName();
    $size = Input::file('foto')->getSize();
    Input::file('foto')->move(public_path().'/foto/',$filename);
    $data = $request->all();
    $data = array(
        'jdl_id'=>Input::get('jdl_id'),
        'deskripsi'=>Input::get('deskripsi'),
        'ppj_id'=>Input::get('ppj_id'),
        'status'=>Input::get('status'),
        'deadline'=>Input::get('deadline'),
        'filenya'=>Input::file('filenya'),
        'foto'=>$filename);
        Project::create($data);
        return redirect('ios');
    
    
    
    
}

/**
 * Display the specified resource.
 *
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */

  public function getView(){
    return view('project.index');
}

public function insertFile(){
    
    $file= Input::file('filenya');
    
  $rules = array(
        'filenya' => 'required|max:20000|mimes:doc,docx,jpeg,png,jpg,pdf'
        ); 
    
    $validator = Validator::make(Input::all(), $rules);
    
   if ($validator->fails()) {

        // redirect our user back with error messages       
        $messages = $validator->messages();
        // send back to the page with the input data and errors
        return Redirect::to('project.index')->withInput()->withErrors($validator);

      }else if ($validator->passes()) {
       
      // checking file is valid.
        if (Input::file('filenya')->isValid()) {

          //$destinationPath = 'images/profile/'; // upload path
        $extension = Input::file('filenya')->getClientOriginalExtension(); // getting image extension
        $filenya = rand(11111,99999).'.'.$extension; // renameing image
            
            
      // uploading file to given path

            //$destinationPath = '../uploads';//its refers proj/uploads
            $destinationPath = 'up_file';//its refers proj/public/up_file directry


            $data=array(
                'filenya' => $filenya,
            );
            
            FileModel::insert($data);


            $upload_success = $file->move($destinationPath, $filenya);
            $notification = array(
                'message' => 'File Uploaded successfully!', 
                'alert-type' => 'success'
            );

            return Redirect::to('project.index')->with($notification);


       
       
   }
    
    
}else 
   {
        $notification = array(
                    'message' => 'uploaded file is not valid!', 
                    'alert-type' => 'error'
                );

            return Redirect::to('404')->with($notification);
       
       
   }
    
    
}




public function show($id)
{
    //
}

/**
 * Show the form for editing the specified resource.
 *
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */

/**public function edit($id)
{
    
   $data ['project'] = Project::find($id);
    return view('project.edit',$data);
    
}
*/

/**
 * Update the specified resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */

/**public function update(Request $request, $id)
{
    
    $data = $request->all();
    $project = Project::find($id);
    $project->update($data);
    return redirect('pro');
    
}
*/

/**
 * Remove the specified resource from storage.
 *
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function destroy($id)
{
    $project = Project::find($id);
    $project->delete();
    return redirect('ios')->with('message', 'sudah dihapus');
}

}

and this my create.blade.php

@extends('layouts.template')

@section('content')

Create Project IOS

<!-- Main content -->
<section class="content">
  <div class="row ">
    <div class="col-md-6 ">
        @if (count($errors)>0)
           <ul>
             @foreach ($errors->all() as $error)
               <li>{{$error}}</li>
             @endforeach
           </ul>
        @endif

        <form action="/adpro" method="post">
            <div class="form-group">
                <label>Nama Project</label>
                <input class="form-control" type="text" name="project" value="" placeholder="Nama Project">
            </div>
            
            <div class="form-group">
                <label>Nama PO</label>
                <select class="form-control" name="po_id">
                    @foreach ($user as $use)
                        <option value="{{$use->id}}">{{$use->name}}</option>
                    @endforeach
                </select>
            </div>
            
            <div class="form-group">
              <label>Nama Document</label>
              <input class="form-control" type="text" name="doc" value="" placeholder="Nama Document">
            </div>
            
            <div class="form-group">
              <label>Deadline</label>
              <input class="form-control" type="date" name="deadline">
            </div>

            <input type="hidden" name="_token" value="{{csrf_token()}}">
            <input class="btn btn-primary btn-sm" type="submit" value="submit">
        </form>
      </div>          
    </div>
  </div>

@endsection

0 likes
0 replies

Please or to participate in this conversation.