Drezard Posted June 9, 2007 Share Posted June 9, 2007 How would I create basic upload script. I just want an upload script so I can upload .php files to my webserver. I have this code from php.net: <?php $uploaddir = 'C:/xampp/htdocs/xampp/'; $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>"; ?> but, that always gives me a 'Possible file attack' error whenever i try and upload a .php file. Can someone please fix that up so i can use it to upload .php files. Thanks, Daniel Link to comment https://forums.phpfreaks.com/topic/54847-upload-script/ Share on other sites More sharing options...
chwebdesigns Posted June 9, 2007 Share Posted June 9, 2007 Why don't you just use FTP? Anyway, there is abit of a code here which a wrote a while ago, so I am not too sure whether it works, ect. As I can't remember. This lets you upload any type of file to a certain folder, with a browse button too. You could, create a drop down list, or radio buttons to make it upload to a different folder. The only thing is though, I think you have to set the folder permissions to 777, before you can use this script, otherwise it just dosen't allow it. Let me know how it goes, <?php //set where you want to store files //in this example we keep file in folder upload //$HTTP_POST_FILES['ufile']['name']; = upload file name //for example upload file name cartoon.gif . $path will be upload/cartoon.gif $path= "upload/".$HTTP_POST_FILES['ufile']['name']; // change "upload/" to the location on the server if($ufile !=none) { if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path)) { echo "<h1>Successful</h1><BR/>"; //$HTTP_POST_FILES['ufile']['name'] = file name //$HTTP_POST_FILES['ufile']['size'] = file size //$HTTP_POST_FILES['ufile']['type'] = type of file echo "<strong>File Name :</strong>".$HTTP_POST_FILES['ufile']['name']."<BR/>"; echo "<strong>File Size :</strong>".$HTTP_POST_FILES['ufile']['size']."<BR/>"; echo "<strong>File Type :</strong>".$HTTP_POST_FILES['ufile']['type']."<BR/>"; } else { echo "Error"; } } ?> From Cal Link to comment https://forums.phpfreaks.com/topic/54847-upload-script/#findComment-271354 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.