Title: move_upload_file in wordpress
Last modified: August 21, 2016

---

# move_upload_file in wordpress

 *  [girll](https://wordpress.org/support/users/girll/)
 * (@girll)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/move_upload_file-in-wordpress/)
 * I want to upload file in wordpress, but I wanna use move_upload_file, not wordpress’s
   upload function. SO this is my code:
 *     ```
       <html>
       <body>
       <form action="" method="post" enctype="multipart/form-data">
          <p>
             <label for="file">Select a file:</label> <input type="file" name="userfile" id="file"> <br />
             <button name = "submit">Upload File</button>
          <p>
       </form>
   
       <?php
       function uploadImg ($height, $width) {
   
       	$allowed_filetypes = array('.jpg','.gif','.bmp','.png', '.php');
       	$max_filesize = 5242880;
       	$upload_path =plugins_url().'/gallery_plugin/imgs/';
       	echo $upload_path;
   
       	$filename = $_FILES['userfile']['name'];
       	$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1);
       	$img = $upload_path . $filename;
   
       	if(!in_array($ext,$allowed_filetypes))
       		die('The file you attempted to upload is not allowed.');
   
       	if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize)
       		die('The file you attempted to upload is too large.');
   
       	if(move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_path . $filename)){
       	   	// echo 'Your file upload was successful!';
       		echo "<img src =".$img." width =".$width." height = ".$height.">";
       		}
       	else{
       		echo 'There was an error during the file upload.  Please try again.';
       		}
       }
   
       $width="200px";
       $height="300px";
       if (isset($_POST['submit'])){
       uploadImg ($width, $height);
       }
       ?>
       </body>
       </html>
       ```
   
 * But I get such error:
 * Warning: move_uploaded_file([http://localhost/wordpress-gallery/wp-content/plugins/gallery_plugin/imgs/Koala.jpg](http://localhost/wordpress-gallery/wp-content/plugins/gallery_plugin/imgs/Koala.jpg))[
   function.move-uploaded-file]: failed to open stream: HTTP wrapper does not support
   writeable connections in C:\xampp\htdocs\wordpress-gallery\wp-content\plugins\
   gallery_plugin\views\images_add.php on line 28
 * What can be the problem?
    Thanks!

The topic ‘move_upload_file in wordpress’ is closed to new replies.

## Tags

 * [upload file](https://wordpress.org/support/topic-tag/upload-file/)

 * 0 replies
 * 1 participant
 * Last reply from: [girll](https://wordpress.org/support/users/girll/)
 * Last activity: [12 years, 9 months ago](https://wordpress.org/support/topic/move_upload_file-in-wordpress/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
