Jump to content

upload help


XxDeadmanxX

Recommended Posts

I have image uploader. But i want  it to resize and rename if its possible. Here is the code im using
[code]<?php



echo('NOTE: This may take few seconds.
<br>

Upload images:


<FORM ENCTYPE="multipart/form-data" ACTION="upload.php" METHOD="POST">

The file: <INPUT TYPE="file" NAME="userfile">

<INPUT TYPE="submit" VALUE="Upload">

</FORM>');



$path = "uploads/";

$max_size = 200000000;



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



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



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

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



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



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

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

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



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

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

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

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

}



$my_file = $HTTP_POST_FILES['userfile']['name'];

?> [/code]
Link to comment
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.