@istables if you use php artisan serve from your host, you still can connect to mysql in your VM. same config used to connect with sequelpro.
Ah right I did not know that thanks for the heads up! @faisal_arbain
@faisal_arbain I changed my local connection to:
'host' => 'localhost',
'database' => 'bookstore',
'username' => 'homestead',
'password' => 'secret',
but unable to connect when using artisan serve
@lstables can you try this config:
'mysql' => array(
'driver' => 'mysql',
'host' => '127.0.0.1:33060',
'database' => 'bookstore',
'username' => 'homestead',
'password' => 'secret',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
p/s: i unable to try this config. after upgrade my mac to yosemite, i lost my mcrypt.
@faisal_arbain that was it, thanks man!
Question now is.... If i upload a pdf or anything else less than 1MB it uploads and moves the uploads/csv directory, but trying to upload this CSV file that's over 8MB it doesn't upload to the directory am I missing something?
public function upload()
{
if (Input::hasFile('file')) {
$file = Input::file('file');
$name = time() . '-' . $file->getClientOriginalName();
$moved = $file->move(public_path() . '/uploads/csv', $name);
$csv = new Reader($moved);
$csv->setOffset(0);
$nbInsert = $csv->each(function ($row) use (&$sth) {
DB::table('books')->insert(
array(
'ref' => (isset($row[0]) ? $row[0] : ''),
'date' => (isset($row[1]) ? $row[1] : ''),
'sold' => (isset($row[2]) ? $row[2] : ''),
'author' => (isset($row[3]) ? $row[3] : ''),
'title' => (isset($row[4]) ? $row[4] : ''),
'place_date' => (isset($row[5]) ? $row[5] : ''),
'description' => (isset($row[6]) ? $row[6] : ''),
'price' => (isset($row[7]) ? $row[7] : ''),
'keywords' => (isset($row[8]) ? $row[8] : ''),
'classification' => (isset($row[9]) ? $row[9] : ''),
'cost' => (isset($row[10]) ? $row[10] : ''),
'notes' => (isset($row[11]) ? $row[11] : ''),
'isbn' => (isset($row[12]) ? $row[12] : ''),
'publisher' => (isset($row[13]) ? $row[13] : ''),
'pub_date' => (isset($row[14]) ? $row[14] : ''),
'binding' => (isset($row[15]) ? $row[15] : ''),
'condition' => (isset($row[16]) ? $row[16] : '')
)
);
return true;
});
}
return Redirect::to('admin/books')->with('flash_success', 'Upload completed & new data inserted.');
}
Form for uploading:
{{ Form::open(['route' => 'books.upload', 'class' => 'form-horizontal', 'files' => true]) }}
<p>Upload CSV file</p>
{{ Form::file('file') }}
<button class="btn btn-success">Upload</button>
{{ Form::close() }}
could it be limitation in upload_max_filesize or post_max_size?
Route::get('test',function()
{
var_dump('POST: '.ini_get('post_max_size'));
var_dump('UPLOAD: '.ini_get('upload_max_filesize'));
});
That returns:
string 'POST: 0' (length=7)
string 'UPLOAD: 120M' (length=12)
¿Have you tried restarting PHP?
sudo service php5-fpm restart
or
sudo /etc/init.d/php5-fpm restart
Yes again that was something taylor gave me also so I made the changes and then restarted
try this:
var_dump($_FILES);
:D
Please or to participate in this conversation.