Jump to content

[SOLVED] unknown file upload issue


cs1h

Recommended Posts

Hi,

 

I have written a script to upload a file and change it's name before saving.

 

the code is

 

<?php

$password = createRandomPassword();  
$image = $_FILES['photo']['name'];
$ext = substr($image, strrpos($image, '.') + 1);
$target = "image_convert/";
$newName = $target . "$password.$ext"; 

if ($_FILES['photo']['tmp_name']) {
           $finalName = $newName;
} else {
           $finalName = $target . "dfxfd.jpg";
}

if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $finalName))
{
echo "The file has been uploaded as $finalName";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}

?>

 

But the problem is that it always returns the message

Sorry, there was a problem uploading your file.

 

Can anyone see why this may be?

 

Thanks,

Colin

Link to comment
https://forums.phpfreaks.com/topic/125869-solved-unknown-file-upload-issue/
Share on other sites

Archived

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

×
×
  • Create New...

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.