Jump to content


Photo

Upload problem!


  • Please log in to reply
2 replies to this topic

#1 feri_soft

feri_soft
  • Members
  • PipPipPip
  • Advanced Member
  • 147 posts

Posted 25 October 2006 - 04:16 PM

<?php

$file1 = $_REQUEST['file1'];
$file2 = $_REQUEST['file2'];
$file3 = $_REQUEST['file3'];
$file4 = $_REQUEST['file4'];
include 'thumbnail_generator.php';
$uploadDir = '/upload/';
if(!empty($file1))
{
	$fileName = $_FILES['file1']['name'];
	$tmpName  = $_FILES['file1']['tmp_name'];
	$fileSize = $_FILES['file1']['size'];
	$fileType = $_FILES['file1']['type'];

    // get the file extension first
	$ext      = substr(strrchr($fileName, "."), 1); 
	
	// generate the random file name
	include 'db.php';
$query  = "SELECT * FROM `listings` ORDER by listid DESC LIMIT 1";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
  $randName = $row['listid'];
}	
	// and now we have the unique file name for the upload file
    $filePath = $uploadDir . $randName . '-1' . '.' . $ext;

    // move the files to the specified directory
	// if the upload directory is not writable or
	// something else went wrong $result will be false
    $result = move_uploaded_file($tmpName, $filePath);
	if (!$result) {
		echo "Error uploading file";
		exit;
	}
	$filePath2 = $uploadDir . $randName . '-1' . '-small' . '.' . $ext;
	createthumb($filePath,$filePath2,100,100);
   
        $fileName  = trashinput($fileName);
        $filePath  = trashinput($filePath);
		$filePath2  = trashinput($filePath2);
  

	$query = "INSERT INTO images (imgid, listid, imgurl, thumburl, date) ".
			 "VALUES ('$randName', '$filePath', '$filePath2', now())";

    mysql_query($query) or die('Error, query failed : ' . mysql_error());                    

    
    echo "<br>File uploaded<br>";
	 
}	
?>

It just dont want to upload.Forget the resizes they work fine when are seperated but the upload isnt working help needed very fast! PLEASE

#2 mschrank99

mschrank99
  • Members
  • PipPip
  • Member
  • 16 posts

Posted 25 October 2006 - 06:28 PM

You've gotta cut and paste the error message it's given you so we can compare it to the code, otherwise it doesn't help us.

-Matthew

#3 feri_soft

feri_soft
  • Members
  • PipPipPip
  • Advanced Member
  • 147 posts

Posted 26 October 2006 - 01:54 PM

I found the problem but cant find a solution.When the if clause is removed everything is fine.Upload,database,thumbs.But the if causes problems and the script just gives a blanc screen.Can someone find a solution for replacing the if??




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users