BaconBeast321 Posted August 5, 2006 Share Posted August 5, 2006 Hi there. Here is my code: (It is straight from a tutorial site)Makeaj.php------------<form action="makeajcom.php" method="post"><br>Type (or select) Filename: <input type="file" name="uploadFile"><input type="submit" value="Upload File"></form>Makeajcom.php---------------<?phpmove_uploaded_file ($_FILES['uploadFile'] ['tmp_name'], "/uploads/{$_FILES['uploadFile'] ['name']}")?>///////////--------------//////////////I figured it would be easy to get this bit done, but it doesnt seem to be working!uploads is a directory below both php files..Any help would be really appreciated Quote Link to comment https://forums.phpfreaks.com/topic/16628-cant-get-file-upload-script-working/ Share on other sites More sharing options...
ignace Posted August 5, 2006 Share Posted August 5, 2006 Well because my previous post was way to long and had way to much options, I filtered it a bit and came up with this, It still need some altering though.. but it should work[code]<?phpfunction Upload($File, $UploadFolder='', $NewFilename='', $UploadExtFilter='', $UploadMaxSize='') { if (substr($UploadFolder, -1) != '/') { $UploadFolder .= '/'; } if (!is_dir($UploadFolder)) { // Error message comes here..., or try to create the folder } if (!is_writable($UploadFolder)) { // Error message comes here..., or make it writable } if (is_uploaded_file($File['tmp_name'])) { $Filesize = $File['size']; $Filename = $File['name']; if (!preg_match('/\\.('.$UploadExtFilter.')$/i', $Filename)) { if ($Filesize > $UploadMaxSize) { // file to big.. } if ($NewFilename) { $Filename = $NewFilename; } if (file_exists($UploadFolder . $Filename)) { // Oeps already exists... } if (move_uploaded_file($File['tmp_name'], $UploadFolder . $Filename)) { // Success return true; } else { // No success return false; } } else { // Extensions not allowed } }}if ($_POST['submit']=='Upload') { if (Upload($_FILES['uploadIt'], '/upload/', 'my_file.txt', 'bat|com|php', 8000)) { echo 'jipii'; } }?><form action="" method="post" enctype="multipart/form-data"><input type="file" name="uploadIt"> <input type="submit" name="submit" value="Upload"></form>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16628-cant-get-file-upload-script-working/#findComment-69743 Share on other sites More sharing options...
xec Posted August 5, 2006 Share Posted August 5, 2006 // THIS IS WORKING UPLOAD SCRIPT , I AM USING IT....//------------------------------------------------if(strlen($HTTP_POST_FILES['ufile']['name']) <1){echo ("ERROR ! No file to upload" );exit();}$upload_path = $HTTP_POST_FILES['ufile']['name'];//echo $upload_path;/*if(!is_dir($_POST['path1'])){echo ' ERROR ! Path not defined properly';exit();}*/$store_dir = "/upload/";/*if( !is_dir($store_dir) ){ echo("Specified directory is not valid... Exiting"); @unlink($HTTP_POST_FILES['ufile']['tmp_name']); exit();}*/if( copy($HTTP_POST_FILES['ufile']['tmp_name'],$store_dir.$HTTP_POST_FILES['ufile']['name']) ){ echo("Uploaded ".$HTTP_POST_FILES['ufile']['name']." successfully.");}/*if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $upload_path)){ echo 'FILES ,'.$HTTP_POST_FILES['ufile']['name'].' uploaded successfully';}*/else { echo 'ERROR : error in uploading '; }unlink($HTTP_POST_FILES['ufile']['tmp_name']); Quote Link to comment https://forums.phpfreaks.com/topic/16628-cant-get-file-upload-script-working/#findComment-69788 Share on other sites More sharing options...
BaconBeast321 Posted August 6, 2006 Author Share Posted August 6, 2006 Hey guys, the basics are now complete, however still one last hurdle to tackle,When the user locates this persons journal page I need to display all the pictures for this journal.Now when the user uploaded the pictures they were stored in a folder /upload and each picture had the nameof the journaltitle then a number e.gbeachtrip1.jpg beachtrip2.jpgHow do I first check to see if pictures were uploaded and then display them?... Quote Link to comment https://forums.phpfreaks.com/topic/16628-cant-get-file-upload-script-working/#findComment-70019 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.