JoeSalmi Posted February 8, 2014 Share Posted February 8, 2014 Can someone please help me with this. I'm pulling my hair out. I have manually uploaded videos via FTP into a folder on my website and I am trying to get a code that I can use with a button that will tell my database to update it with all the current files... then display the files on the page. Can anyone help? I have the database all set up and what I need to do is get is the movie name, upload date, and the file size into the database FROM the folder I have all the movies in. That way I can repull that information from the database back into the website and display it all. Currently I am displaying all the files in the folder onto a webpage and it's starting to get laggy and time consuming to load. Not to mention I have plans on using some sort of pagenation to help with load times. Let me know if anyone still doesn't understand my endgame here. I'm not sure I am exactly explaining this the right way. Joe Quote Link to comment https://forums.phpfreaks.com/topic/286033-i-need-some-help-with-myphpadminmysql-and-grabbing-files-from-website/ Share on other sites More sharing options...
Ch0cu3r Posted February 8, 2014 Share Posted February 8, 2014 (edited) What have you tried so far? You can use glob to list all files in a directory. With glob you can easily filter out files you want to deal with. For example if you only want .mp4, .flv, and ogv files you can use "$videoDir/*.{mp4,flv,ogv}" as the pattern, making sure to use the GLOB_BRACE flag. You can get the date the file was created using filectime. For the file size you would use filesize Edited February 8, 2014 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/286033-i-need-some-help-with-myphpadminmysql-and-grabbing-files-from-website/#findComment-1468173 Share on other sites More sharing options...
JoeSalmi Posted February 10, 2014 Author Share Posted February 10, 2014 Currently I am grabbing the file names by using straight PHP code and opendir("./movies"); My problem is I have files over 2 gigs and I am getting errors galore AND I can't use pagination to lower the amount shown on each page... I did find a snippet to display filesize over 2GB but now I am having an issue displaying fileatime with files over 2GB function showsize($file) { if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { if (class_exists("COM")) { $fsobj = new COM('Scripting.FileSystemObject'); $f = $fsobj->GetFile(realpath($file)); $file = $f->Size; } else { $file = trim(exec("for %F in (\"" . $file . "\") do @echo %~zF")); } } elseif (PHP_OS == 'Darwin') { $file = trim(shell_exec("stat -f %z " . escapeshellarg($file))); } elseif ((PHP_OS == 'Linux') || (PHP_OS == 'FreeBSD') || (PHP_OS == 'Unix') || (PHP_OS == 'SunOS')) { $file = trim(shell_exec("stat -c%s " . escapeshellarg($file))); } else { $file = filesize($file); } if ($file < 1024) { return $file . ' Byte'; } elseif ($file < 1048576) { return round($file / 1024, 2) . ' KB'; } elseif ($file < 1073741824) { return round($file / 1048576, 2) . ' MB'; } elseif ($file < 1099511627776) { return round($file / 1073741824, 2) . ' GB'; } elseif ($file < 1125899906842624) { return round($file / 1099511627776, 2) . ' TB'; } elseif ($file < 1152921504606846976) { return round($file / 1125899906842624, 2) . ' PB'; } elseif ($file < 1180591620717411303424) { return round($file / 1152921504606846976, 2) . ' EB'; } elseif ($file < 1208925819614629174706176) { return round($file / 1180591620717411303424, 2) . ' ZB'; } else { return round($file / 1208925819614629174706176, 2) . ' YB'; } } I'm am having a hard time finding people to help get where I need to be so any help anyone can give would be greatly appreciated. I think what I am trying to do is use a php code to get mysql to get all the data for me from the server. Then I would like to use all the data in the database to paste back onto the site. That way the page isn't trying to load all the actual files and stuff, only when someone clicks the link to download it. I might not need to do it that way so if someone would like to talk 1 on 1 I would be more than happy doing it that way to try and explain myself better. Send me a message and we can chat live via facebook or something else. Quote Link to comment https://forums.phpfreaks.com/topic/286033-i-need-some-help-with-myphpadminmysql-and-grabbing-files-from-website/#findComment-1468337 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.