Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.