Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Where is the error coming from?
Old 06-10-2008, 03:14 PM Where is the error coming from?
goheadtry's Avatar
Webmaster Talker

Posts: 730
Name: John
Location: United States of America, California
Trades: 0
Where is the error coming from?
You may only upload movies.
Sorry your file was not uploadedYou may only upload movies.
the file name I tried to upload is k.avi
PHP Code:
<?php
  
  $filepath 
'/home/forbushj/www/vidtemp/';
  
$filetypes = array('video/x-ms-asf''video/x-msvideo''video/x-flv''video/quicktime''video/mp4''video/mpeg''video/x-ms-wmv');
  
$title addslashes($_GET['title']);
  
$descr addslashes($_GET['descr']);
  
$src addslashes($_GET['src']); 
// Check for errors:
if (addslashes($_GET['agree'] = 0))
{
echo(
"You must agree or you can't upload");
}
else
{

if (!empty (
$title) || !empty ($descr) || !empty ($src) || !empty ($_FILES['uploaded']['tmp_name'])) {
      if (
$uploaded_size 104857600$error_msg .= 'Your file is too large. Only files 100MB and less are allowed<br />';
      if (!
in_array($uploaded_type$filetypes)) $error_msg .= 'You may only upload movies.<br />';
      
      if (
$error_msg)
      {
        echo 
$error_msg 'Sorry your file was not uploaded';
      }
      else if (
move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
      {
        
$file $_FILES['uploaded']['tmp_name'];
        
$ext substr($file, ((strrpos($file'.') !== false) ? strrpos($file'.') : strlen($file)), strlen($file));
        
$filename date('Y-m-d-H-i-s') . '_' str_replace(' ''_'basename($file$ext));
        
$filename preg_replace('/[\\\/:*?"<>|]/'''$filename);
        
        if (
is_file($filepath $file))
        {
          
$output = array();
          
          
exec('ffmpeg -i "' escapeshellarg($file) . '" -an -ss 00:00:03 -t 00:00:01 -r 1 -y -s 150x100 -f mjpeg "/home/forbushj/www/pic/video/' escapeshellarg($filename) . '.jpg"'$output$exit_code_pic);
          
exec('ffmpeg -i "' escapeshellarg($file) . '" -ar 22050 -ab 32 -f flv -s 320x240 "/home/forbushj/www/vidd/' escapeshellarg($filename) . '.flv"'$output$exit_code_vid);
          
          if (!
is_array($output)) $error_msg 'Sorry, there was a problem uploading your file.';
          
          if (
$exit_code)
          {
            
error_log('ffmpeg exec returned ' $exit_code);
            
$error_msg 'Sorry, there was a problem uploading your file.';
          }
          
          if (!
$error_msg)
          {
    
mysql_connect("localhost""REMOVED""REMOVED") or die(mysql_error());
            
mysql_query("
              INSET INTO forbushj_onetest.video (title, descr, pic, locat, src)
              VALUES (
                '" 
mysql_real_escape_string($title) . "',
                '" 
mysql_real_escape_string($descr) . "',
                '" 
mysql_real_escape_string($filename ".jpg") . "',
                '" 
mysql_real_escape_string($filename ".flv") . "',
                '" 
mysql_real_escape_string($src) . "'
              )
            "
);
            echo 
"upload successful";
            
unlink(' . escapeshellarg($file) . ');
          }
        }
        else
        {
          
$error_msg 'Sorry, there was a problem uploading your file.';
        }
      }
      else
      {
        
$error_msg 'Sorry, there was a problem uploading your file.';
      }
      
      if (
$error_msg) echo $error_msg;
} else {
    echo 
'You must fill out all fields!';
}
}
  
?>
__________________
Free $1 gift card when you signup at
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

goheadtry is offline
Reply With Quote
View Public Profile Visit goheadtry's homepage!
 
 
Register now for full access!
Old 06-10-2008, 08:07 PM Re: Where is the error coming from?
vangogh's Avatar
Post Impressionist

Latest Blog Post:
Why Responsive Design?
Posts: 10,815
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
It doesn't look like you defined avi as one of your allowable $filetypes.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 06-10-2008, 09:13 PM Re: Where is the error coming from?
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
Your vars $uploaded_size and $uploaded_type are undefined.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 06-10-2008, 10:14 PM Re: Where is the error coming from?
Junior Talker

Posts: 3
Name: Chad
Trades: 0

vangogh is right you need to make it an allowed type.
__________________

Please login or register to view this content. Registration is FREE
phparrow is offline
Reply With Quote
View Public Profile
 
Old 06-11-2008, 12:14 AM Re: Where is the error coming from?
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
No vangogh is not right, 'video/x-msvideo' that's where it's defined. mgraphic is correct though, he's using bad variables.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 06-11-2008, 12:45 AM Re: Where is the error coming from?
goheadtry's Avatar
Webmaster Talker

Posts: 730
Name: John
Location: United States of America, California
Trades: 0
Quote:
Originally Posted by mgraphic View Post
Your vars $uploaded_size and $uploaded_type are undefined.
Okay how do I define them though if it is part of the upload?
$uploaded_size is the maximum size of a possible uploaded file
$uploaded_type is the mime type of the uploaded file

so how does the script go so these are defined?
__________________
Free $1 gift card when you signup at
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

goheadtry is offline
Reply With Quote
View Public Profile Visit goheadtry's homepage!
 
Old 06-11-2008, 12:58 AM Re: Where is the error coming from?
dlaroche22's Avatar
Skilled Talker

Posts: 84
Name: Dustin Laroche
Trades: 0
you should be able to get the variables from the file being attached if I am correct. I don't have a lot of time to do any research, but you should be able to call the file being uploaded and get the information. I could and probably am wrong, I just thought I would throw a quick 2 cents in.
__________________
Under Construction, But A Work In Progress
Webhosting isn't cheap, sponsors are important

Please login or register to view this content. Registration is FREE
dlaroche22 is offline
Reply With Quote
View Public Profile
 
Old 06-11-2008, 01:06 AM Re: Where is the error coming from?
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
http://us2.php.net/features.file-upload
$_FILES['uploaded']['type'] or ['size'] instead of type.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 06-11-2008, 07:01 PM Re: Where is the error coming from?
vangogh's Avatar
Post Impressionist

Latest Blog Post:
Why Responsive Design?
Posts: 10,815
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
Jerod thanks for teaching me something new. I didn't realize 'video/x-msvideo' was for avi, but it makes sense.

And seeing what Keith said I agree the problem is the undefined variables.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 06-11-2008, 10:01 PM Re: Where is the error coming from?
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
http://www.w3schools.com/media/media_mimeref.asp that should be useful.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 06-12-2008, 07:43 PM Re: Where is the error coming from?
vangogh's Avatar
Post Impressionist

Latest Blog Post:
Why Responsive Design?
Posts: 10,815
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
Definitely helpful. I don't do a lot of work with video, audio, etc. so I've never really gone in and learned all those before.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Reply     « Reply to Where is the error coming from?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.33858 seconds with 12 queries