Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script help

Status
Not open for further replies.

darkprince

Programmer
Jun 4, 2002
165
AU
please help im new to php and i got this script off free php script section. its an image upload script and in his demo it works but when i test it after i click upload it just comes with a blank screen and doesn't work. i emailed bloodys webmaster but got now response so please help, below is the script.



upload.php
--------------------------
<FORM ENCTYPE=&quot;multipart/form-data&quot; ACTION=&quot;imageupload.php&quot; METHOD=&quot;POST&quot;>
The file: <INPUT TYPE=&quot;file&quot; NAME=&quot;userfile&quot;>
<INPUT TYPE=&quot;submit&quot; VALUE=&quot;Upload&quot;>
</FORM>
---------------------------


imageupload.php
----------------------------
<?php

// Image file upload by Bloody
// // email: info@bloodys.com
// If you use this script, please put a link back to
$path = &quot;&quot;;
$max_size = 200000;

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 &quot;The file is too big<br>\n&quot;; exit; }
if (($HTTP_POST_FILES['userfile']['type']==&quot;image/jpg&quot;) || ($HTTP_POST_FILES['userfile']['type']==&quot;image/JPG&quot;) || ($HTTP_POST_FILES['userfile']['type']==&quot;image/jpeg&quot;)) {

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

$res = copy($HTTP_POST_FILES['userfile']['tmp_name'], $path .
$HTTP_POST_FILES['userfile']['name']);
if (!$res) { echo &quot;upload failed!<br>\n&quot;; exit; } else { echo &quot;upload sucessful<br>\n&quot;; }

echo &quot;File Name: &quot;.$HTTP_POST_FILES['userfile']['name'].&quot;<br>\n&quot;;
echo &quot;File Size: &quot;.$HTTP_POST_FILES['userfile']['size'].&quot; bytes<br>\n&quot;;
echo &quot;File Type: &quot;.$HTTP_POST_FILES['userfile']['type'].&quot;<br>\n&quot;;
} else { echo &quot;Wrong file type<br>\n&quot;; exit; }

}

?>
----------------------


thanks in advance
 
well u dont need anybody's script i will tell u how upload works:

$fl=$HTTP_POST_FILES['userfile']
//stores the uploaded file in fl.
//userfile is the name of the file field.

$path=&quot;PATH_HERE&quot;;
$path.=&quot;\\$fl['name']&quot;;

//$fl['name'] - name of the file

copy($HTTP_POST_FILES['userfile']['tmp_name'], $path)
//path is the path where u want to save the file.

thats it to it. the rest is fancy stuff. u will understand it only slowly.


HTH

Known is handfull, Unknown is worldfull
 
im learning php but not up to this yet, could you just edit the bloodys script so it will work as it doesn't work. i will learn it in time but i just need this script to work as i need to implement it into a website. i don't know what to put in the path field as well if i wanted to file to be stored in the folder upload.php is in.

please tell me how to get this script to work

thanks in advance
 
well i dont think i will have the time to debug bloody's script but path means the path where u want to save the file.

try this simle path:
$path=&quot;c:\\&quot;;


Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top