I am developing an app with 2 files:
index.php (application container)
process.php (called in ajax)
index.php
<?php
include 'config.php';
include 'lib/functions.php';
require_once 'lib/sdk/facebook.php';
$facebook = new Facebook(array(
'appId' => APP_ID,
'secret' => SECRET
));
$userID = $facebook->getUser();
if (!$userID)
{
$scope = 'read_stream, publish_stream, user_likes, user_photos, user_status, friends_hometown, friends_location, friends_likes, photo_upload';
$params = array(
'scope' => $scope,
'redirect_uri' => "https://apps.facebook.com/".APP_NAME."/"
);
$loginUrl = $facebook->getLoginUrl($params);
}
else
{
$access_token = $facebook->getAccessToken();
}
?>
<!doctype html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<title>Facebook App</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link href="/css/style.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="/js/jquery.js"></script>
</head>
<body style="margin:0 !important; padding: 0 !important;">
{ SOME HTML }
<script type="text/javascript">
function loadData()
{
$.ajax({
url: "process.php",
type: 'POST',
cache: false,
data: {
id_sessione: function(){return $("#id_sessione").val();}
},
dataType: "json",
success: function(data) {
if (data.status == "FAILURE")
alert('failure');
else
console.log(data);
}
});
}
/********* INIT ********/
$(document).ready(function(){
if ($("#userID").val() != "0")
loadData();
else
top.location = '<?php echo $loginUrl; ?>';
});
</script>
<input id="id_sessione" type="hidden" value="<?php echo session_id(); ?>" />
<input id="userID" type="hidden" value="<?php echo $userID; ?>" />
<div id="fb-root"></div>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId: '<?php echo APP_ID; ?>',
frictionlessRequests: true
});
FB.Canvas.setAutoResize(7);
};
(function() {
var e = document.createElement('script');
e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/it_IT/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
</body>
</html>
and process.php
<?php
session_id($_POST['id_sessione']);
session_start();
include 'config.php';
include 'lib/functions.php';
require_once 'lib/sdk/facebook.php';
set_time_limit(120);
$memory_limit = ini_set('memory_limit', '512M');
try
{
$facebook = new Facebook(array(
'appId' => APP_ID,
'secret' => SECRET
));
$userID = $facebook->getUser();
$user_profile = $facebook->api('/me');
{ SOME FQL QUERIES AND DATA PROCESSING }
echo json_encode(array(
'status' => 'SUCCESS',
.... other info
));
} catch (Exception $e) {
$handle = fopen(ROOT_PATH.'/log/'.$userID.'_'.uniqid().'.txt', 'a+') or die('Cannot open file');
fwrite($handle, $e->getMessage()."\n");
fwrite($handle, $e->getTraceAsString()."\n");
fclose($handle);
echo json_encode(array(
'status' => 'FAILURE'
));
}
In 95% of cases application works fine but sometimes $facebook->api('/me'); trows the exception "An active access token must be used to query information about the current user." and the $userID is equal to 0.
In order to have the same session id in all files I have to start manually session with the session_id passed by index.php in POST. This is because some browser (IE, safari) don't pass cookies of third party pages in iframe. (http://stackoverflow.com/questions/9930671/safari-3rd-party-cookie-iframe-trick-no-longer-working)
Any suggestions?
Thank you
check whether the session value is passing properly or not?
Related
This is Welcome controller method
public function send_otp()
{
echo 'in';
die;
$phone = $_POST['mobile'];
if ($phone != '') {
$mobile_detail = $this->welcome_model->check_if_already_mobile_no($phone);
if (!empty($mobile_detail)) {
if ($mobile_detail['is_verified'] == 'yes') {
$message = 'Already Verified.';
echo json_encode(array('status' => 'error', 'message' => $message));
exit;
} else {
$this->welcome_model->delete_mobile_no($phone);
}
}
$otp = self::generateRandomNo();
$this->welcome_model->insert_mobile_detail($phone, $otp);
$link = file_get_contents("http://49.50.67.32/smsapi/httpapi.jsp?username=aplusv&password=aplusv1&from=APLUSV&to=$phone&text=$otp&coding=0");
$status = '';
if ($link != '') {
$status = 'success';
$message = 'Successfully Otp send to your no.';
} else {
$status = 'error';
$message = 'Error in sending OTP.';
}
echo json_encode(array('status' => $status, 'message' => $message));
exit;
}
}
This is model
public function check_if_already_mobile_no($mobile_no = null)
{
$query = $this->db->get_where('mobile_sms', array('mobile_no' => $mobile_no));
return $query->row_array();
}
public function get_mobile_details($mobile_no = null, $otp = null)
{
$query = $this->db->get_where('mobile_sms', array('mobile_no' => $mobile_no, 'otp' => $otp));
return $query->row_array();
}
public function insert_mobile_detail($phone, $otp)
{
$this->mobile_no = $phone;
$this->otp = $otp;
$this->is_verified = 'no';
$this->created_at = date('Y-m-d H:i:s');
$this->db->insert('mobile_sms', $this);
}
This is view
<div class="container" style="margin-top: 25px;">
<div class="row">
<div class="col-md-12" id="response_msg"></div>
<div class="col-md-4" id="enter_mobile">
<form method="POST" action="#">
<div class="form-group">
<label for="phone">Phone </label>
<input type="text" class="form-control" id="mobile" name="phone" placeholder="Enter Mobile">
</div>
<button type="button" name="send_mobile" id="send_otp" class="btn btn-primary">Submit</button>
</form>
</div>
<script src="assets/js/jquery.js"></script>
<script type="text/javascript">
// var base_url = "<?php echo base_url();?>";
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script>
$(function () { // start of doc ready.
$("#send_otp").on('click', function (e) {
var mobile = $('#mobile').val();
alert(mobile);
$.ajax({
url: '<?php echo site_url('index.php/welcome/send_otp'); ?>',
data: {'mobile': mobile},
type: "post",
dataType: 'json',
success: function (data) {
if (data.status == 'success') {
$('#response_msg').html('<div class="alert alert-success" role="alert">' + data.message + '</div>');
$('#mobile_no').val(mobile);
$('#enter_mobile').hide();
$('#verify_otp_form').show();
} else {
$('#response_msg').html('<div class="alert alert-danger" role="alert">' + data.message + '</div>');
}
}
});
});
in ajax is not getting call ie $.ajax is not working here and my controller ie welcome with method send_otp is not called here.
why my function in controller is not getting called
how to solve the issue
what is the proper way to call the controller function using base_url
i have check the console also it is not showing any error
I noticed that you are using site_url() slightly incorrectly: don't write index.php there, just use site_url('welcome/send_otp')
Don't forget you have an unconditional die() at the top of your send_otp method - it will prevent any code below itself from executing
$(document).ready(function(){
$("#log").click(function(){
var name = $("#name").val();
var email = $("#email").val();
var img = $("#img").val();
$.ajax({
url:"ajax.php",
type:"POST",
async:false,
data:{
"postD" :1,
"nameD" : name,
"emailD" : email,
"imgD" : img
},
success:function(data){
$("#name").val('');
$("#email").val('');
$("#img").val('');
}
});
});
});
function displaydata(){
$.ajax({
url:"ajax.php",
type:"POST",
async:false,
data:{
"displayP":1
},
success:function(data){
$("#datafromDb").html(data);
}
});
}
<?php
include("db.php");
$sql = "
CREATE TABLE IF NOT EXISTS temptable (
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(20) NOT NULL,
email VARCHAR(20) NOT NULL,
PRIMARY KEY(id)
);
";
mysqli_query($connect, $sql);
if (isset($_POST['postD'])){
if(!empty($_POST['nameD']) && !empty($_POST['emailD'])&& !empty($_FILES['imgD'])) {
$emailP = $_POST['emailD'];
$nameP = $_POST['nameD'];
$imgP = $_FILES['imgD']['name'];
$tmpname = $_FILES['imgD']['tmp_name'];
$folder = "upload/";
move_uploaded_file($tmpname, $folder.$imgP);
$insert = "INSERT INTO `inserteddata` (`name`, `email`,`img`)
VALUES('{$nameP}','{$emailP}','{$imgP}')";
$qry = mysqli_query($connect, $insert);
if($qry) {
echo "inserted";
}
}else {
echo "make sure all fields are filled";
}
}
if(isset($_POST['displayP'])){
$sel = "SELECT * FROM `inserteddata`";
$res = mysqli_query($connect, $sel);
while($row=mysqli_fetch_array($res)) {
echo "Name = ".$row['name']."<br><br><br>";
}
}
?>
<?php
$connect = mysqli_connect("localhost", "root", "", "ajaxinsert");
if(!$connect) {
echo "database connection error".mysqli_error();
}else {
echo "connected successfuly<br><br><br>";
}
?>
<!DOCTYPE html>
<html>
<head>
<title>ajax insert</title>
<script type="text/javascript" src="jquery-3.2.1.js"></script>
<script type="text/javascript" src="ajax.js"></script>
</head>
<body>
<div id="datafromDb">
<script type="text/javascript">
document.write(displaydata());
</script>
</div>
<br>
<br>
<form enctype="multipart/form-data" action="" method="post">
<input type="text" id="name"><br><br>
<input type="email" id="email"><br><br>
<input type="file" id="img" name="img"><br><br>
<input type="submit" value="Login" >
<a href="" id="log" >add</a>
</body>
</html>
Am trying to upload image using ajax php and jquery what am i doing wrong here. the image should be uploaded without refreshing the page. i have tried the above code. if your see any prolem, help!!
The thing is i want to move the uploaded file to the upload folder and insert the image name to the database as a BLOB.
You can use FormData objects but you need to write the code in plain Javascript because I think JQuery doesn't support it yet. Please read this for more information https://developer.mozilla.org/en-US/docs/Web/API/FormData/Using_FormData_Objects
I want to develop simple ajax with laravel5.2 with this code
This oneline_help.php view
<html>
<head>
<title>Ajax Example</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
function getMessage(){
$.ajax({
type:'POST',
url:'/getmsg',
data:'_token = <?php echo csrf_token() ?>',
success:function(data){
$("#msg").html(data.msg);
}
});
}
</script>
</head>
<body>
<div id = 'msg'>This message will be replaced using Ajax.
Click the button to replace the message.</div>
<?php
echo Form::button('Replace Message',['onClick'=>'getMessage()']);
?>
</body>
</html>
This is the routes
Route::get('/ajax','front#support');
Route::post('/getmsg','Hello#index');
This is front #support
public function support()
{
return view('online_help', array('title' => 'Welcome', 'description' => '', 'page' => 'online_help','subscribe'=>"",'brands' => $this->brands));
}
This is Hallo #index controller
public function index(){
echo"i in in hello index";
$msg = "This is a simple message.";
return response()->json(array('msg'=> $msg), 200);
}
The button appear But when click on it, The text doesn't change .
Please tell me why and how to resolve it.
Here is my working example of AJAX....
You don't need to add token in your ajax request, make it global so with every ajax request, your CSRF token will be added automatically.
In your HTML Head section add this meta tag
<meta name="csrf-token" content="<?php echo csrf_token() ?>">
Then add this code in your Javascript tags. this will add CSRF token in every ajax request.
Note this required jquery file should be included in your page. once include call this method below from the file.
<script type="text/javascript">
var csrf_token = $('meta[name="csrf-token"]').attr('content');
$.ajaxSetup({
headers: {"X-CSRF-TOKEN": csrf_token}
});
</script>
I have modified your method....
<script>
function getMessage(){
$.ajax({
type:'POST',
url:'/getmsg',
data:'_token = <?php echo csrf_token() ?>', //remove this line
dataType:'json', // you skipped this line
beforeSend:function(){
alert('loading....'); //this will show loading alert
},
success:function(data){
$("#msg").html(data.msg);
},
error:function(){
alert('loading error...')
}
});
}
</script>
what i intend to do, is to use uploadify to upload a file, change its name in uploadify.php for the value of time() ,save it , and return the name of the saved file back to the HTML, im not sure how to do it, currently im using this as guide
http://www.uploadify.com/documentation/uploadify/customizing-the-server-side-upload-script/
and this is my code so far
index.php
'<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"
type="text/javascript"></script>
<script src="jquery.uploadify.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="uploadify.css">
<style type="text/css">
body {
font: 13px Arial, Helvetica, Sans-serif;
}
</style>
</head>
<body>
<form>
<div id="queue"></div>
<input id="file_upload" name="file_upload" type="file" multiple="true">
</form>
<script type="text/javascript">
<?php $timestamp = time();?>
$(function() {
$('#file_upload').uploadify({
'formData' : {
'timestamp' : '<?php echo $timestamp;?>',
'token' : '<?php echo md5('unique_salt' . $timestamp);?>',
'name' : 'somename'
},
'method' : 'post',
'swf' : 'uploadify.swf',
'uploader' : 'uploadify.php',
onUploadComplete : function(data, file , response){
alert('The file was saved to: ' + data);
alert(response);
}
});
});
$(document).ready(function() {
$("#FormSubmit").click(function (e) {
var img = 'localhost/uploads/'+ $("#hidden").val;
var cuenta_sap = $("#cuenta_sap").val();
var ubicacion = $("#ubicacion").val();
var codigo_centro_beneficio = $("#codigo_centro_beneficio").val();
var nombre = $("#nombre").val();
var proyecto = $ ("#proyecto").val();
var departamento = $ ("#departamento").val();
var tipo_activo = $("#tipo_activo").val();
var proveedor = $("#proveedor").val();
var modelo = $("#modelo").val();
var numero_serie = $("#numero_serie").val();
var marca = $ ("#marca").val();
var numero_remision = $("#numero_remision").val();
var myData ='cuenta_sap='+ cuenta_sap + '&ubicacion='+ ubicacion +
'&codigo_centro_beneficio='+ codigo_centro_beneficio + '&nombre=' + nombre + '&proyecto='
+ proyecto + '&departamento='+ departamento + '&tipo_activo=' + tipo_activo
+'&proveedor='+ proveedor +'&modelo=' + modelo + '&numero_serie=' + numero_serie +'&marca='
+ marca + '&numero_remision='+ numero_remision;
e.preventDefault();
if(cuenta_sap==''||ubicacion==''||codigo_centro_beneficio==''
||nombre==''||proyecto==''||departamento
==''||tipo_activo==''||proveedor==''||modelo==''
||numero_serie==''||marca==''||numero_remision=='')
{
alert("Formato incompleto!");
return false;
}
$("#FormSubmit").hide(); //hide submit button
$("#LoadingImage").show(); //show loading image
$.ajax({
type: "POST", // HTTP method POST or GET
url: "response.php", //Where to make Ajax calls
dataType:"text", // Data type, HTML, json etc.
data:myData, //
success:function(result){
$("#responds").delay(10000).fadeIn();
$("#responds").append("<li class='res'>"+result+"</li>");
$('.res').remove();
$("#proyecto").val(''); //empty text field on successful
$("#departamento").val(''); //empty text field on successful
$("#tipo_activo").val(''); //empty text field on successful
$("#modelo").val(''); //empty text field on successful
$("#numero_serie").val(''); //empty text field on successful
$("#marca").val(''); //empty text field on successful
$("#numero_remision").val(''); //empty text field on successful
$("#cuenta_sap").val(''); //empty text field on successful
$("#ubicacion").val(''); //empty text field on successful
$("#nombre").val(''); //empty text field on successful
$("#codigo_centro_beneficio").val(''); //empty text field on successful
$("#FormSubmit").show(); //show submit button
$("#LoadingImage").hide(); //hide loading image
},
error:function (xhr, ajaxOptions, thrownError){
$("#FormSubmit").show(); //show submit button
$("#LoadingImage").hide(); //hide loading image
alert(thrownError);
}
});
});
$("body").on("click", "#responds .del_button", function(e) {
e.preventDefault();
var clickedID = this.id.split('-'); //Split ID string (Split works as PHP explode)
var DbNumberID = clickedID[1]; //and get number from array
var myData = 'recordToDelete='+ DbNumberID; //build a post data structure
$('#item_'+DbNumberID).addClass( "sel" ); //change background of this element by adding class
$(this).hide(); //hide currently clicked delete button
$.ajax({
type: "POST", // HTTP method POST or GET
url: "response.php", //Where to make Ajax calls
dataType:"text", // Data type, HTML, json etc.
data:myData, //Form variables
success:function(response){
//on success, hide element user wants to delete.
$('#item_'+DbNumberID).fadeOut();
},
error:function (xhr, ajaxOptions, thrownError){
//On error, we alert user
alert(thrownError);
}
});
});
});
</script>
<div class="content_wrapper" id="wrapepr">
<div class="form_style">
<input name="hidden" id="hidden" type="text"></input>
<br>
<a>Datos</a>
<br>
<input name="cuenta_sap" id="cuenta_sap" placeholder="cuenta sap" class="input"></input>
<select name="departamento" class="input" id="departamento">
<option value = "">seleccione departamento</option>
<?php
include("db.php");
$stmt = $db->prepare("SELECT `id`, `departamento` FROM `departamentos`");
$stmt->execute();
$stmt->bind_result($id,$departamento);
while ($stmt->fetch()){
echo "<option value='$id'>$departamento</option>";
}
?>
</select>
<select name="proyecto" class="input" id="proyecto" >
<option value = "" >seleccione proyecto</option>
<?php
$stmt = $db->prepare("SELECT `id` ,`proyecto` FROM `proyectos`");
$stmt->execute();
$stmt->bind_result($id,$proyecto);
while ($stmt->fetch()){
echo "<option value='$id'>$proyecto</option>";
}
?>
</select>
<select name="tipo" class="input" id="tipo_activo">
<option value = "" class="input" >tipo de activo</option>
<?php
$stmt = $db->prepare("SELECT `id` ,`tipo` FROM `tipo_activo`");
$stmt->execute();
$stmt->bind_result($id,$tipo_activo);
while ($stmt->fetch()){
echo "<option value='$id' class='input'>$tipo_activo</option>";
}
?>
</select>
<select name="proveedor" class="input" id="proveedor">
<option value = "" class="input" >seleccione proveedor</option>
<?php
$stmt = $db->prepare("SELECT `id` ,`nombre` FROM `proveedores`");
$stmt->execute();
$stmt->bind_result($id,$nombre);
while ($stmt->fetch()){
echo "<option value='$id' class='input'>$nombre</option>";
}
?>
</select>
<input name="codigo_centro_beneficio" id="codigo_centro_beneficio" placeholder="codigo centro
beneficio" class="input"></input>
<input name="nombre" id="nombre" placeholder="nombre" class="input"></input>
<input name="modelo" id="modelo" placeholder="modelo" class="input"></input>
<input name="numero_serie" id="numero_serie" placeholder="numero_serie" class="input">
</input>
<input name="marca" id="marca" placeholder="marca" class="input"></input>
<input name="numero_remision" id="numero_remision" placeholder="numero remision" class="input">
</input>
<input name="upload" id="upload" class="input" type="file"></input>
<button id="FormSubmit">registrar</button>
<img src="images/loading.gif" id="LoadingImage" style="display:none" />
</div>
<ul id="responds" >
</ul>
</div>
</body>
</html>'
and uploadify.php
'
$targetFolder = '/uploads'; // Relative to the root
$verifyToken = md5('unique_salt' . $_POST['timestamp']);
if (!empty($_FILES) && $_POST['token'] == $verifyToken) {
$now = time();
$name = $_POST('name')FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
// Validate the file type
$fileTypes = array('jpg','jpeg','gif','png'); // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);
$targetFile = rtrim($targetPath,'/') . '/' . $now .'.'. $fileParts['extension'];
echo rtrim($targetPath,'/') . '/' . $now .'.'. $fileParts['extension'];
if(file_exists($targetFile)){
++$now;
$targetFile = rtrim($targetPath,'/') . '/' . $now .'.'. $fileParts['extension'];
$name $targetPath,'/') . '/' . $now .'.'. $fileParts['extension'];
echo $name;
}
if (in_array($fileParts['extension'],$fileTypes)) {
move_uploaded_file($tempFile,$targetFile);
}
else {
echo 'Invalid file type.';
}
?>'
I found the answer to this, after a while of searching and reading uploadify manuals, it turns out if you use onUploadComplete, and you just upload one single fine, the method will never excecute, and it will keep waiting for more files, instead for one file only, you have to use onUploadSuccess, and read the data returned by it using file,data,response as parameters.
I'm using Symfony2 and I would like to use the BlueImp plugin, basic setup.
Actually, I have a form in which you can load 3 pictures and one song (it is for an artist registration).
As a start, I try to implement the plugin for just one picture. But when I select a file in my input "picture 1", nothing happens.. What is wrong ?
<html>
<head>
<script type="text/javascript" src="{{ asset('bundles/mybundle/js/jquery-file-upload/js/vendor/jquery.ui.widget.js') }}"></script>
<script type="text/javascript" src="{{ asset('bundles/mybundle/js/jquery-file-upload/js/jquery.iframe-transport.js') }}"></script>
<script type="text/javascript" src="{{ asset('bundles/mybundle/js/jquery-file-upload/js/jquery.fileupload.js') }}"></script>
</head>
<form id="myForm" action="{{ path('MyBundle_artist_new') }}" {{ form_enctype(form) }} method="post" novalidate>
<div class="field">
{{ form_label(form.picture1 "Picture 1") }}
{{ form_widget(form.picture1) }}
</div>
<input type="submit" value="Register"/>
</form>
<script type="text/javascript">
$(document).ready(function(){
$('#myform_picture1').fileupload(
{
dataType: 'json',
url:'{{path('MyBundle_ajax_upload_picture') }}',
done: function (e, data) {
$.each(data.result.files, function (index, file) {
$('<p/>').text(file.name).appendTo(document.body);
});
}
});
});
</script>
Here is upload handler (the action for the url {{path('MyBundle_ajax_upload_picture') }} :
<?php
public function ajaxUploadPicture()
{
$request = $this->get('request');
$uploaded_file = $request->files->get('myform_picture1');
if ($uploaded_file)
{
$picture1 = $this->processImage($uploaded_file);
$picture1->setPath('pictures/artist/' . $picture1);
$em->persist($picture1);
$em->flush();
$response = 'success';
}
else $response= 'error';
$response = new Response(json_encode(array('response'=>$response)));
$response->headers->set('Content-Type', 'application/json');
return $response;
}
public static function processImage(UploadedFile $uploaded_file)
{
$path = 'pictures/artist/';
$uploaded_file_info = pathinfo($uploaded_file->getClientOriginalName());
$filename = uniqid() . "." .$uploaded_file_info['extension'];
$uploaded_file->move($path, $filename);
return $filename;
}
You should check what you get from ajax request ex:
$('#myform_picture1').fileupload(
{
dataType: 'json',
url:'{{path('MyBundle_ajax_upload_picture') }}',
done: function (e, data) {
$.each(data.result.files, function (index, file) {
$('<p/>').text(file.name).appendTo(document.body);
});
},
always: function (e, data) {
console.log(data);
}
});
I am not sure about this line $uploaded_file = $request->files->get('myform_picture1');
you sure that your file input name is myform_picture1 ?
Please try $uploaded_file = $request->files->get('myform[picture1]', array(), true);