Chrisj Posted March 14, 2015 Share Posted March 14, 2015 I'm using the PHP script for a video web site, and have added the ability to show the user's avatar (that he adds to his User Profile) as his uploaded video's Thumbnail image, in place of the thumbnail that's generated by the uploaded video itself (if the User leaves his avatar blank, the thumbnail generated by the video will show). It works successfully when the videos uploaded are short and not when the videos are longer. When I comment-out the added code (the nine commented-out lines near the bottom of the convertor.php code -posted below), all files upload successfully and the video-generated thumbnail appears. When I remove the commenting-out of those lines of code, only shorter videos show the avatar thumbnail, and only shorter videos(200KB for example) upload at all. Longer videos (25,000KB for example) don't appear to have uploaded. (maybe it's a timed-out thing when that code is looking for a thumbnail?) Any insight or suggestion will be appreciated. $sql = "SELECT file_name FROM pictures WHERE user_id = $user_id LIMIT 1"; $result = mysql_query($sql); $row = mysql_fetch_array($result); $pic_file = $row['file_name']; $output_file = $base_path."/uploads/thumbs/".$file_name_no_extension.'.jpg'; $input_file = $base_path."/pictures/".$pic_file; echo "Input file = ".$input_file; echo " and Output file = ".$output_file."<br>"; copy($input_file, $output_file); Quote Link to comment Share on other sites More sharing options...
iarp Posted March 15, 2015 Share Posted March 15, 2015 Do you have display_errors On ? If not, have you looked at the web server error logs? How long is max_execution_time? What about sufficient filesize allowed via upload_max_size, post_max_size in php.ini ? If it takes too long to upload, it'll time out. If it's bigger than the server allows it'll only stop once that limit has been reached. Your SQL query, what happens if $row is empty because the user_id wasn't found? That'll throw an error. What happens if the filename with no extension isn't located in the path you're specifying and then you try to copy it? Nothing about what you've posted is actual thumbnail generation, it's just a copy script without any checks to ensure the file it's trying to copy actually exists, or that the user exists. What happens if the output file already exists, you'll be overwriting someone elses thumbnail with another users. if (!empty($row) { $input_file = .... $output_file = .... if (!file_exists($output_file)) { if (file_exists($input_file)) { copy($input_file, $output_file); } else { echo 'input file already exists'; } } else { echo 'output file already exists'; } } else { echo 'no user found'; } Quote Link to comment 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.