/
  • مشکل در بارگذاری تصویر در لاراول

  • ارسال پاسخ   امتیاز موضوع:
    • 0 رأی - میانگین امیتازات: 0
    • 1
    • 2
    • 3
    • 4
    • 5

    حالت موضوعی | حالت خطی مشکل در بارگذاری تصویر در لاراول
    نویسنده پیام
    alirezayaee1991 آفلاین
    عضو جدید
    **

    ارسال‌ها: 2
    تاریخ عضویت: ۱۳۹۷ آبان ۱۳
    اعتبار: 0
    تشکرها : 0
    ( 0 تشکر در 0 ارسال )
    ارسال: #1
    Tongue مشکل در بارگذاری تصویر در لاراول
    با سلام خدمت تمامی دوستان عزیز.

    این کدهای فرم من در html:
    کد PHP:
    <form id="register" enctype="multipart/form-data" method="POST" action="{{ url('/request/register') }}">
                                <
    div class="form-group row has-danger">
                                    @
    csrf
                                    
    <div class="col-sm-6">
                                        <
    label for="email" class="col-sm-6 col-form-label text-right">نام کاربری:</label>
                                        <
    div class="col-sm-10">
                                            <
    input type="email" class="fsax form-control form-control-danger{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" id="email" value="{{ old('email') }}" placeholder="مثال:info@jameeco.local">
                                            @if (
    $errors->has('email'))
                                                <
    span class="invalid-feedback" role="alert">
                                                <
    strong>{{ $errors->first('email') }}</strong>
                                            </
    span>
                                            @endif
                                            <
    small class="form-text text-muted">نام کاربری بصورت فرمت ایمیل باید وارد گردد</small>
                                        </
    div>
                                        <
    label for="password" class="col-sm-6 col-form-label text-right">گذرواژه:</label>
                                        <
    div class="col-sm-10">
                                            <
    input type="password" class="fsax form-control form-control-danger{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" id="password" required>
                                            @if (
    $errors->has('password'))
                                                <
    span class="invalid-feedback" role="alert">
                                                <
    strong>{{ $errors->first('password') }}</strong>
                                            </
    span>
                                            @endif
                                            <
    small class="form-text text-muted">گذرواژه باید مناسب و غیرقابل حدس باشد</small>
                                        </
    div>
                                        <
    label for="confirm-password" class="col-sm-6 col-form-label text-right">تایید گذرواژه:</label>
                                        <
    div class="col-sm-10">
                                            <
    input type="password" class="fsax form-control form-control-danger" name="password_confirmation" id="password-confirm" required>
                                            <
    small class="form-text text-muted">تکرار گذرواژه برای صحت گذرواژه گذاری</small>
                                        </
    div>
                                        <
    label for="name" class="col-sm-6 col-form-label text-right">نام و نام خانوادگی:</label>
                                        <
    div class="col-sm-10">
                                            <
    input type="text" class="fsax form-control form-control-danger{{ $errors->has('name') ? ' is-invalid' : '' }}" name="name" id="name" value="{{ old('name') }}" placeholder="مثال:علی رحمتی">
                                            @if (
    $errors->has('name'))
                                                <
    span class="invalid-feedback" role="alert">
                                                <
    strong>{{ $errors->first('name') }}</strong>
                                            </
    span>
                                            @endif
                                            <
    small class="form-text text-muted">نام و نام خانوادگی حتما بصورت فارسی وارد شود</small>
                                        </
    div>
                                        <
    label class="col-sm-6 col-form-label text-right">جنسیت:</label>
                                        <
    div class="col-sm-10">
                                            <
    div class="col-sm-4">
                                                <
    label for="sex_more" class="col-sm-2 col-form-label text-right">نامشخص</label>
                                                <
    input checked="checked" type="radio" id="sex_more" name="sex" class="fsax radio radio_sex" value=""/>
                                            </
    div>
                                            <
    div class="col-sm-4">
                                                <
    label for="men" class="col-sm-2 col-form-label text-right">آقا</label>
                                                <
    input type="radio" id="men" name="sex" class="fsax radio radio_sex" value="1"/>
                                            </
    div>
                                            <
    div class="col-sm-4">
                                                <
    label for="women" class="col-sm-2 col-form-label text-right">خانم</label>
                                                <
    input type="radio" id="women" name="sex" class="fsax radio radio_sex" value="2"/>
                                            </
    div>
                                            <
    small class="form-text text-muted">لطفا نوع جنسیت با دقت انتخاب گردد</small>
                                        </
    div>
                                        <
    label class="col-sm-6 col-form-label text-right">دسترسی به نرم افزار:</label>
                                        <
    div class="col-sm-10">
                                            @if(
    Auth::user()->access_soft<=200)
                                                <?
    php $func_dis_1='' ?>
                                            @else
                                                <?php $func_dis_1='disabled' ?>
                                            @endif
                                            <div class="col-sm-4">
                                                <label for="access_more" class="col-sm-2 col-form-label text-right">عادی</label>
                                                <input checked="checked" {!! $func_dis_1 !!} type="radio" id="access_more" name="access" class="fsax radio radio_access" value="0"/>
                                            </div>
                                            @if(Auth::user()->access_soft>=100)
                                                <?php $func_dis_2='' ?>
                                            @else
                                                <?php $func_dis_2='disabled' ?>
                                            @endif
                                            <div class="col-sm-4">
                                                <label for="viewer" class="col-sm-2 col-form-label text-right">نظارتی</label>
                                                <input type="radio" {!! $func_dis_2 !!} id="viewer" name="access" class="fsax radio radio_access" value="1"/>
                                            </div>
                                            @if(Auth::user()->access_soft>100)
                                                <?php $func_dis_3='' ?>
                                            @else
                                                <?php $func_dis_3='disabled' ?>
                                            @endif
                                            <div class="col-sm-4">
                                                <label for="manager" class="col-sm-2 col-form-label text-right">مدیریتی</label>
                                                <input type="radio" {!! $func_dis_3 !!} id="manager" name="access" class="fsax radio radio_access" value="2"/>
                                            </div>
                                            <small class="form-text text-muted">دسترسی به نرم افزار باید به تایید مدیرکل بخش برسد</small>
                                        </div>
                                    </div>
                                    <div class="col-sm-6">
                                        <label class="col-sm-6 col-form-label text-right">تصویر آواتار:</label>
                                        <div class="col-sm-10">
                                            <div class="circle">
                                                <!-- User Profile Image -->
                                                <img class="profile-pic" src="{!! url('/assets/img/users/avatars/default-avatar.png') !!}">

                                                <!-- Default Image -->
                                                <!-- <i class="fa fa-user fa-5x"></i> -->
                                            </div>
                                            <div class="p-image">
                                                <i class="fa fa-camera upload-button"></i>
                                                <input name="image" id="image" class="form-control file-upload" type="file" accept="image/*"/>
                                            </div>
                                            <small class="form-text text-muted">عکس بصورت پرسنلی و بهترین سایز آن 200در200پیکسل است</small>
                                        </div>
                                        <label class="col-sm-6 col-form-label text-right">تاریخ تولد:</label>
                                        <div class="col-sm-10">
                                            <input type="text" class="fsax form-control form-control-danger" name="birthday" id="birthday">
                                            <small class="form-text text-muted">تاریخ تولد را با دقت درج نمایید</small>
                                        </div>
                                        <label for="post" class="col-sm-6 col-form-label text-right">سمت/پست/مسئولیت:</label>
                                        <div class="col-sm-10">
                                            <input type="text" class="fsax form-control form-control-danger" name="post" id="post" placeholder="مثال:سرپرست نرم افزار">
                                            <small class="form-text text-muted">پست باید بصورت حقیقی باشد،در صورت نادرست بودن جایگاه اعلامی،توسط مدیر اصلاح خواهد شد</small>
                                        </div>
                                        <label for="mobile" class="col-sm-6 col-form-label text-right">تلفن همراه/موبایل:</label>
                                        <div class="col-sm-10">
                                            <input type="text" class="fsax form-control form-control-danger" name="mobile" id="mobile" placeholder="مثال:0915XXXXXXX">
                                            <small class="form-text text-muted">تلفن تماس حتما باید همراه بوده و در دسترس باشد</small>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-10">
                                    <button onclick="sumbit_form()" class="btn btn-success" type="button"><i class="fa fa-save"></i> ثبت کاربر </button>
                                </div>
                            </form> 
    این تابع من در جی کوئری هستش:
    کد PHP:
    function sumbit_form() {
                var 
    file = $("#image").val
                
    var datastring = $(".fsax").serialize();
                var 
    token '{{ csrf_token() }}';
                var 
    base_url "{{ url('/request/register') }}";
                $.
    ajax({
                    
    type'POST',
                    
    urlbase_url,
                    
    dataType"json",
                    
    data: {
                        
    '_token'token,
                        
    datastring datastring ,
                        
    file file,
    },
                    
    success: function (data) {
                        var 
    substr data['msg'];

                        $.
    each(substr , function(indexval) {
                            
    alert(val)
                        });
                    },
                    
    error: function () {
                        
    alert('خطا');
                    }
                });

            }; 
    اما متاسفانه عکس رو نمیتونم با این روش ارسال کنم.
    progressdata هم در jquery استفاده میکنم اصلا token لاراول رو نمیشناسه.

    لطفا راهنمایی کنید
    (آخرین ویرایش در این ارسال: ۱۳۹۷ آبان ۱۳ ۰۳:۵۸ عصر، توسط alirezayaee1991.)
    ۱۳۹۷ آبان ۱۳ ۰۳:۴۹ عصر
    یافتن ارسال‌ها پاسخ با نقل قول
     تشکر شده توسط :
    « قدیمی تر | تازه‌ تر »

    ارسال پاسخ
    پرش به انجمن:


    کاربرانِ درحال بازدید از این موضوع: 1 مهمان
    IranPHP.org | تماس با ما | بازگشت به بالا | بازگشت به محتوا | بایگانی | پیوند سایتی RSS