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 this error coming from and how do I correct the error?
Old 06-11-2008, 06:26 PM where is this error coming from and how do I correct the error?
goheadtry's Avatar
Webmaster Talker

Posts: 730
Name: John
Location: United States of America, California
Trades: 0
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpfhQYAQ' to '' in /home/forbushj/public_html/uploadscript.php on line 26
Sorry, there was a problem uploading your file.


The uploaded path is supposed to be /home/forbushj/www/vidtemp/ the name of the uploaded file.


PHP Code:
<?php
  $uploaded_size 
$_FILES['uploaded']['size'];
  
$uploaded_type $_FILES['uploaded']['type'];
  
  
$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-11-2008, 06:53 PM Re: where is this error coming from and how do I correct the error?
PeachyJuice's Avatar
Super Talker

Posts: 116
Name: Michele T.
Location: Ny, Ny
Trades: 1
I don't see where you define $target, so the file can't be uploaded without a place to go. You probably want to replace that with $filepath.
__________________
Freelance web+graphic designer and PHP developer.

Please login or register to view this content. Registration is FREE
PeachyJuice is offline
Reply With Quote
View Public Profile
 
Old 06-11-2008, 08:31 PM Re: where is this error coming from and how do I correct the error?
goheadtry's Avatar
Webmaster Talker

Posts: 730
Name: John
Location: United States of America, California
Trades: 0
Can everyone else verify this just to make certain.
__________________
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, 10:06 PM Re: where is this error coming from and how do I correct the error?
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
She's mostly right, you need to use $filepath instead of $target, but also you need to specify the file by name, new script:
PHP Code:
else if (move_uploaded_file($_FILES['uploaded']['tmp_name'], $filepath.$_FILES['uploaded']['name'])) 
the ['name'] is the name that the user gave it while uploading it.
__________________
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, 12:38 AM Re: where is this error coming from and how do I correct the error?
goheadtry's Avatar
Webmaster Talker

Posts: 730
Name: John
Location: United States of America, California
Trades: 0
Now I am getting another error after changing $target to make it equal to $filepath.$_FILES['uploaded']['name'].


Warning: preg_replace() [function.preg-replace]: Unknown modifier ':' in /home/forbushj/public_html/uploadscript.php on line 31
Sorry, there was a problem uploading your file.

PHP Code:
<?php
  $uploaded_size 
$_FILES['uploaded']['size'];
  
$uploaded_type $_FILES['uploaded']['type'];
  
$target $filepath.$_FILES['uploaded']['name'];
  
$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""forbushj_videou""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


Last edited by goheadtry; 06-12-2008 at 12:39 AM..
goheadtry is offline
Reply With Quote
View Public Profile Visit goheadtry's homepage!
 
Old 06-12-2008, 01:07 AM Re: where is this error coming from and how do I correct the error?
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
Escape the colon. Also:
$target = $filepath.$_FILES['uploaded']['name'];
$filepath = '/home/forbushj/www/vidtemp/';
Switch those two lines around.
__________________
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!
 
Reply     « Reply to where is this error coming from and how do I correct the error?
 

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.34116 seconds with 12 queries