dirntknow Posted April 28, 2010 Share Posted April 28, 2010 Just trying this basic code for uploading a file (image) and works locally but I get a 500-Internal Error when uploaded to my site...why would this happen? Thanks!! <?php echo "<pre>"; print_r($_FILES); echo "</pre>"; $target_path = "./upload/".$_FILES['uploadedfile']['name']; move_uploaded_file($_FILES['uploadedfile']['tmp_name'],$target_path); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form enctype="multipart/form-data" action="uploader.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Choose a file to upload: <input name="uploadedfile" type="file" /> <input type="submit" value="Upload File" /> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/200043-basic-file-upload-only-works-locally/ Share on other sites More sharing options...
swatisonee Posted April 28, 2010 Share Posted April 28, 2010 i use // the foll 2 lines are in the file that the viewer see //<tr><td><font face="Tahoma" color="#0000FF" size="2"><b>Upload a file:</td><td><input name="userfile" //type="file"><font size="1" color="#FF0080"> File size should not exceed 2MB</font></td></tr><p><p> if(!($_FILES["userfile"]["name"]=="")) { $uploaddir="./filesadded/"; //copy the file to some permanent location if (move_uploaded_file($_FILES["userfile"]["tmp_name"], $uploaddir.$_FILES["userfile"]["name"])) { echo("<p>File uploaded<p><p>"); } else { echo ("<p>Error in uploading file! Please try again.<br>"); if($_FILES['userfile']['error']==1) echo "<font color=red>Error: File size exceeds maximum permissible limit of 2MB</font><p><p>"; } } Link to comment https://forums.phpfreaks.com/topic/200043-basic-file-upload-only-works-locally/#findComment-1049986 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.