Jump to content

Archived

This topic is now archived and is closed to further replies.

feri_soft

Upload problem!

Recommended Posts

[code]<?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>";

}
?>[/code]

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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??

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.