hanhao Posted June 1, 2006 Share Posted June 1, 2006 problem for my uploading file scripthi i got a problem with my uploading scripthere is the code on the page which shows the upload button.[code]<form enctype="multipart/form-data" action="uploader.php" method="POST"><input type="hidden" name="MAX_FILE_SIZE" value="90000000" />Choose a file to upload: <input name="uploadfile" type="file" /><br /><input type="submit" value="Upload File" /></form> [/code]here is the code taken from php.net, it's in upload.php[code]<?php// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead// of $_FILES.$uploaddir = "/website_root/color_scripts/querypic.jpg";$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);echo '<pre>';if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully uploaded.\n";} else { echo "Possible file upload attack!\n";}echo 'Here is some more debugging info:';print_r($_FILES);print "</pre>";?> [/code]upon uploading i get the following error[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Possible file upload attack!Here is some more debugging info:Array( [uploadfile] => Array ( [name] => querypic.jpg [type] => image/pjpeg [tmp_name] => d:\Program Files\xampp\tmp\phpBB.tmp [error] => 0 [size] => 30489 ))[/quote]can anyone please help? Quote Link to comment https://forums.phpfreaks.com/topic/10921-problem-in-my-uploading-file-script/ Share on other sites More sharing options...
hvle Posted June 1, 2006 Share Posted June 1, 2006 your $uploaddir should be a directory, it is currently a file.change to:$uploaddir = '"/website_root/color_scripts/';or something else.also, the directory must be already created and set to writable (0777) Quote Link to comment https://forums.phpfreaks.com/topic/10921-problem-in-my-uploading-file-script/#findComment-40793 Share on other sites More sharing options...
hanhao Posted June 1, 2006 Author Share Posted June 1, 2006 [!--quoteo(post=378944:date=Jun 1 2006, 12:00 AM:name=hvle)--][div class=\'quotetop\']QUOTE(hvle @ Jun 1 2006, 12:00 AM) [snapback]378944[/snapback][/div][div class=\'quotemain\'][!--quotec--]your $uploaddir should be a directory, it is currently a file.change to:$uploaddir = '"/website_root/color_scripts/';or something else.also, the directory must be already created and set to writable (0777)[/quote]ok here's the change[code]<?php// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead// of $_FILES.[b]$uploaddir = "/website_root/color_scripts/";[/b]$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);echo '<pre>';if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully uploaded.\n";} else { echo "Possible file upload attack!\n";}echo 'Here is some more debugging info:';print_r($_FILES);print "</pre>";?> [/code]the directory existshoW do i set it to writable?? Quote Link to comment https://forums.phpfreaks.com/topic/10921-problem-in-my-uploading-file-script/#findComment-40800 Share on other sites More sharing options...
hvle Posted June 1, 2006 Share Posted June 1, 2006 if the server is on remote server, use ftp, login and set permission to 0777if it's on your local machine, i'm sure you know how. Quote Link to comment https://forums.phpfreaks.com/topic/10921-problem-in-my-uploading-file-script/#findComment-40803 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.