What is not working exactly since both functions do something else...
Mar 1, 2015
42
Level 5
image function not 100%
I'm not sure what is going on, in most of my modules I have an image section where I can upload images and save them, but when I add an image section to another module it doesn't work and I can't seem to figure out why since it's using the same code and that code is working.
this is the code I've been using. create.blade.php
{{ HTML::script('js/test.js') }}
<script type="text/javascript">
var settings = {
url: '{{ asset("upload/upload.php") }}',
dragDrop:true,
multiple : false,
showFileCounter:false,
showDone: false,
fileName: "myfile",
allowedTypes:"jpg,png,gif,pdf",
returnType:"json",
showDelete:true,
}
</script>
<div id="fileuploader" class="testing">Upload</div>
<script>
var uploadObj = $("#fileuploader").uploadFile(settings);
</script>
{{ Form::hidden('image', '', array('id' => 'img-add', 'class' => 'img-hidden')) }}
test.js
$(document).ready(function(){
$(".add-form").submit(function(event){
$(this).find(".testing").each(function(){
var image = [];
$(this).parent().find(".ajax-file-upload-statusbar").each(function() {
image.push($.trim($(this).find(".ajax-file-upload-filename").html()));
});
$(this).parent().find(".img-hidden").val(JSON.stringify(image));
});
$.ajax({
type: 'POST',
url: $(this).attr('action'),
data: $(this).serialize(),
dataType: 'json',
encode : true,
});
});
$(document).on('click', ".ajax-file-upload-statusbar .close", function(){
$(this).parents('.ajax-file-upload-statusbar:first').remove();
});
});
This is a controller one of the modules that is working
public function store()
{
$input = Input::all();
$validation = Validator::make($input, Gallery::$rules);
if($validation->fails()){
return Redirect::route('gallery::index')
->withInput()
->withErrors($validation)
->with('message', 'There were validation errors');
}
if($validation->passes()){
Gallery::create($input);
$galleries = Gallery::all();
return View::make('gallery::index', compact('galleries'));
}
}
and this is the controller of a module that isn't working
public function store()
{
$input = Input::all();
$validation = Validator::make($input, User::$rules);
if($validation->fails()){
return Redirect::route('users::index')
->withInput()
->withErrors($validation)
->with('message', 'There were validation errors');
}
if($validation->passes()){
$input['password'] = Hash::make($input['password']);
User::create($input);
$users = User::all();
return View::make('users::index', compact('users'));
}
}
Please or to participate in this conversation.