lisawebs Posted April 3, 2007 Share Posted April 3, 2007 Hi, I'm using this to upload a file but doesnt work, the php part simply do nothing. PAGE 1 <html><body> <form enctype="multipart/form-data" action="http://www.usa21.net/testupload.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="80000"> Send this file: <input name="userfile" type="file"> <input type="submit" value="send file"> </form></body></html> PAGE 2 php <html><body>this is the php<br> <?php $uploaddir = ''; $uploadfile = $uploaddir. $_FILES['userfile']['name']; print "<pre>"; if ($_FILES['userfile']['size'] > 80000) print "file too big"; else if ($_FILES['userfile']['type'] != "image/jpg) print "file isnt a JPG format" else if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir . $_FILES['userfile']['name'])) { print "file was uploaded:\n"; print_r($_FILES); } else { print "unable to complete operation:\n"; print_r($_FILES); } print "</pre>"; ?> </body></html> Link to comment https://forums.phpfreaks.com/topic/45354-help-need-to-upload-a-file/ Share on other sites More sharing options...
trq Posted April 3, 2007 Share Posted April 3, 2007 We need more information. Do you have errors enabled? If not, enable them, do you get any errors? Link to comment https://forums.phpfreaks.com/topic/45354-help-need-to-upload-a-file/#findComment-220223 Share on other sites More sharing options...
lisawebs Posted April 3, 2007 Author Share Posted April 3, 2007 I dont see any errors, I'm lost, it should be easier! Lisa Link to comment https://forums.phpfreaks.com/topic/45354-help-need-to-upload-a-file/#findComment-220702 Share on other sites More sharing options...
only one Posted April 3, 2007 Share Posted April 3, 2007 <?php $path = ""; if (!isset($HTTP_POST_FILES['userfile'])){ echo " <FORM ENCTYPE=multipart/form-data ACTION=?page=Upload METHOD=POST> <p>The file:<br> <INPUT TYPE=file NAME=userfile><br /> <INPUT TYPE=submit VALUE=Upload> </p> </FORM> "; }else{ if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) { 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")) { if (file_exists($path . $HTTP_POST_FILES['userfile']['name'])) { echo "The file already exists, try calling your file a different name.<br>"; }else{ $res = copy($HTTP_POST_FILES['userfile']['tmp_name'], $path . $HTTP_POST_FILES['userfile']['name']); if (!$res) { echo "upload failed!<br>"; exit; } else { echo "upload sucessful<br><br>"; } echo "File Name: ".$HTTP_POST_FILES['userfile']['name']."<br>"; echo "File Path: <a href=uploads/".$HTTP_POST_FILES['userfile']['name']." TARGET=_BLANK>uploads/".$HTTP_POST_FILES['userfile']['name']."</a><br>"; echo "File Size: ".$HTTP_POST_FILES['userfile']['size']." bytes<br>"; echo "File Type: ".$HTTP_POST_FILES['userfile']['type']."<br>"; echo "<img src=uploads/".$HTTP_POST_FILES['userfile']['name']."><br>"; }}}} ?> hasent been tested! ive put some extra file types in there aswell Link to comment https://forums.phpfreaks.com/topic/45354-help-need-to-upload-a-file/#findComment-220718 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.