Jump to content

How to upload file in php mvc framework


PranAher

Recommended Posts

I am new to mvc , I have down loaded frame work from http://www.php-mini.com

 

//CONTROLLER

 

public function  upload_slider(){
          if(isset($_POST['upload'])) {
 
  $slider_model = $this -> loadmodel('slidermodel');
  $slider = $slider_model -> upload_slider(
      $_FILES['IMAGE_PATH'],
  $_POST['title'],
      $_POST['alt']
 
  );
  }
 
//MODEL
//slidermodel
 
 public function upload_slider($IMAGE_PATH = '' ,$title ='',$alt='' ){
       $uploaddir = "slider/";
$new_file_name = explode(".", $IMAGE_PATH['name']);
$new_file_name = $new_file_name[count($new_file_name) - 1];
$new_file_name = uniqid(). "." .$new_file_name;
 
$uploadfile = $uploaddir . basename($new_file_name);
 
move_uploaded_file($IMAGE_PATH['tmp_name'],$uploadfile);
 
      
      }
 
I am failing  to upload image 
can somone help me ?
 
 

 

Link to comment
https://forums.phpfreaks.com/topic/293376-how-to-upload-file-in-php-mvc-framework/
Share on other sites

What errors are you getting when you run the code?

 

Ensure (in development) that error reporting is on so you can debug the code rapidly. 

<?php 

error_reporting(E_ALL);

ini_set('display_errors', 1);

...

 

Additionally, seriously consider using an IDE like Netbeans for writing your code. The built in PHP Linter will make you aware of simple typos in the code.

 

As for your code..

 

* Can the script write to the path 'slider/'?

* Are you following an example from the php-mini framework pages?

 

Cheers,

Ian

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.