Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
File upload problems
JeanAlesi
August 2015
I'm testing a simple file upload using php... I have properly configured php.ini, and also successfully uploaded files to the server using raw php.. All I want to do is save a file into the APPPATH. '/files' folder
This is my code:
//------ FORM -----//
<h2>Upload file</h2>
<form action="tmtrace/upload2" method="post" enctype="multipart/form-data">
Select image to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload Image" name="submit">
</form>
<?php
if (isset($message)) {
echo $message;
}
?>
//-------- CONTROLLER -------------//
public function action_upload2()
{
if (Input::method() == 'POST' && Input::post('submit'))
{
$data = array();
$config = array(
'path' => APPPATH.'/files',
'randomize' => true,
'ext_whitelist' => array('json', 'jpg', 'jpeg'),
);
Upload::process($config);
if (Upload::is_valid()) {
Upload::save();
$data['message'] = 'here';
}
$this->template->title = 'upload';
$this->template->content = View::forge('tmtrace/upload', $data);
}
}
----------------------------------------------------------------------------------------------------
The result of the operation is that the string 'here' is echoed, signaling that that upload is valid, the folder APPPATH . '/files' is always empty
What am I missing?
Harro
August 2015
Which version of Fuel, and of the Upload package are you using (check composer.json)?
It should be 2.0.2 or 2.0.4, and not 2.0.3 (which has bugs in it).
JeanAlesi
September 2015
I'm using fuelphp version 1.7
composer.json has the following:
{
"name": "fuel/core",
"description" : "FuelPHP 1.x Core",
"type": "fuel-package",
"homepage": "
https://github.com/fuel/core
",
"license": "MIT",
"authors": [
{
"name": "FuelPHP Development Team",
"email": "team@fuelphp.com"
}
],
"require": {
"composer/installers": "~1.0"
}
}
Harro
September 2015
Accepted Answer
This is the one in the core folder.
I meant the composer.json in the root of your application installation (the directory in which you find 'oil'.
The latest 1.7 release should contain 2.0.2:
https://github.com/fuel/fuel/blob/1.7/master/composer.json
which should be upgraded to 2.0.4. to fix some bugs.
JeanAlesi
September 2015
I guess you are talking about fuelphp/upload here:
"require": {
"php": ">=5.3.3",
"composer/installers": "~1.0",
"fuel/core": "dev-1.8/develop",
"fuel/auth": "dev-1.8/develop",
"fuel/email": "dev-1.8/develop",
"fuel/oil": "dev-1.8/develop",
"fuel/orm": "dev-1.8/develop",
"fuel/parser": "dev-1.8/develop",
"fuelphp/upload": "2.0.3",
"monolog/monolog": "1.5.*",
"michelf/php-markdown": "1.4.0"
},
Now the question is:
how do I update this?
Harro
September 2015
Read up on the use of composer:
https://getcomposer.org/
Change 2.0.3 to 2.0.4 and run a composer update. That will install the new version.
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,089
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
261
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
Harro
September 2015
JeanAlesi
September 2015