Jump to content

upload Image Problem


proctk

Recommended Posts

Hi I'm trying to use the below code to upload images into a file folder called adImage

 

 

I'm getting this error message

 

 

Warning: copy(C:/Program Files/xampp/htdocs/adImages/dvdPlayer.jpg) [function.copy]: failed to open stream: No such file or directory in C:\Program Files\xampp\htdocs\etreasures\portal\addTreasure.php on line 36

upload failed!

n

 

line 36 = $res = copy($HTTP_POST_FILES['file']['tmp_name'], $path .

 

$HTTP_POST_FILES['file']['name']);

$path = $_SERVER['DOCUMENT_ROOT'] . '/adImages/';

$max_file_size = 300000;

if(isset ($_POST['Submit'])){

if (!isset($HTTP_POST_FILES['file'])) exit;

if (is_uploaded_file($HTTP_POST_FILES['file']['tmp_name'])) {

if ($HTTP_POST_FILES['file']['size']>$max_file_size) { echo "The file is too big<br>n"; exit; }

if (($HTTP_POST_FILES['file']['type']=="image/gif") || ($HTTP_POST_FILES['file']['type']=="image/pjpeg") || ($HTTP_POST_FILES['file']['type']=="image/jpeg") || ($HTTP_POST_FILES['file']['type']=="image/png")) {



if (file_exists($path . $HTTP_POST_FILES['file']['name'])) { echo "The file already exists<br>n"; exit; }



$res = copy($HTTP_POST_FILES['file']['tmp_name'], $path .

$HTTP_POST_FILES['file']['name']);

if (!$res) { echo "upload failed!<br>n"; exit; } else { echo "upload sucessful<br>n"; }

echo "File Name: ".$HTTP_POST_FILES['file']['name']."<br>n";

echo "File Size: ".$HTTP_POST_FILES['file']['size']." bytes<br>n";

echo "File Type: ".$HTTP_POST_FILES['file']['type']."<br>n";

} else { echo "Wrong file type<br>n"; exit; }

$image = $HTTP_POST_FILES['file']['name'];

Link to comment
https://forums.phpfreaks.com/topic/39395-upload-image-problem/
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.