Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

Video upload in module

edited June 10 in Bug Reports

I have a module which lets you upload videos, so far I have tried uploading a file with .webm format and the error I got was 'The file you are trying to upload is not allowed'. I have searched for this error which is common in CI, went to mimes.php and checked the types, also copied the editable_asset_filetypes array into MY_fuel.php and added mp4 and webm in media and assets, checked the input being rendered for upload form and its like this
<input type="file" name="userfile" value="" id="userfile_upload" accept="jpg,jpeg,jpe,png,gif,mov,mpeg,mp3,wav,aiff,pdf,css,zip,svg,webm,mp4">.
Added sanitize_files => FALSE in My_fuel_modules.php.
Started debugging in Upload.php of CI as everywhere I saw the is_allowed_filetype is buggy, and on line 898 ! in_array($ext, $this->allowed_types, TRUE) returns true which in turn returns false and upon printing $this->allowed_types prints this
Array ([0] => jpg [1] => jpeg [2] => jpe [3] => gif [4] => png [5] => zip [6] => svg ).
So it seems you can't upload any files other than these, so how can I add mimes to this array?
$_FILES also gives type as application/octet-stream in Safari.

Comments

  • Apache also has file upload restriction settings

  • please tell how to configure them? So far I don't think that's the issue, since I can see the result of $_FILES.

  • Did you try adding those values to the "images" key too since it appears that you are uploading to that folder?

  • Hmm... so if I wanted to upload video what folder should I choose? One more thing is I named my column as video_image because fuel automatically creates the file input for image.

  • Created a folder named media and changed to that folder now it works fine, but now when I am trying to get models in a page, empty array is being returned.

    {$videos = fuel_model(videos, array(find=all, where=array(published=yes)))}
    {foreach $videos video}
    {fuel_block(array( view=nt_video_gallery_card, vars=array( title=$video->title, date=$video->publish_date, img=$video->video_image ) ))}
    {/foreach}
    

    same code is being used for another model and I also tried changing to that model and it does load that in this code snippet, although in cms module section list is working alright.

  • If you create a static block using PHP syntax instead of the Dwoo templating syntax, do you get any $videos on line one (e.g. exit(count($videos)) ) ?

  • Thought the same thing, okay i'll let you know

  • I have tried calling the same method in a controller and it also produces empty array, thought if something was wrong with params I was calling so I checked the db but the where clause is also fine, also tried with load model in controller but it also gives same result.

  • In your test controller, add the following code after you run the fuel_model code to output the SQL and debug from there:

    $this->videos_model->debug_query();
    
  • Okay the issue was I had previously changed the date_format in MY_config to d/m/Y which caused the datepicker to pick wrong date in module and so the query was correct but due to wrong date it was not returning results, so how can I change the date for query?

  • I'm not quite sure I understand the question about changing the date for the query. Are you meaning the where condition in the query?

  • yes, that's what I meant

  • Do you mean something like this?

    $video->publish_date_format('d/m/Y')
    
  • Where is this being called? This is not about showing the date format on frontend? I meant how can I say where publish_date <= d/m/Y when the query is generated to fetch results from database?

  • You first would want to normalize the date into something MySQL will be able to compare against so you'd need to convert your d/m/Y to a Y-m-d format.
    Then try changing your line to something like the following:

    {$videos = fuel_model(videos, array(find=all, where='publish_date <= "2018-06-16"'))}
    
Sign In or Register to comment.