{"id":2098,"date":"2014-11-30T15:59:52","date_gmt":"2014-11-30T15:59:52","guid":{"rendered":"https:\/\/www.codexworld.com\/?p=2098"},"modified":"2024-07-17T05:59:46","modified_gmt":"2024-07-17T05:59:46","slug":"php-file-upload","status":"publish","type":"post","link":"https:\/\/www.codexworld.com\/php-file-upload\/","title":{"rendered":"How to Upload File in PHP"},"content":{"rendered":"<p>File upload is the most used feature in web applications. PHP provides an easy way to upload file to the server. With PHP, you can upload files or images to the server by writing minimal code. In this tutorial, we&#8217;ll show you how to <b>upload file in PHP<\/b> and build a PHP script to upload file to the directory on the server. With this example <b>PHP file upload script<\/b> you can upload all types of files including images to the server in PHP.<\/p>\n<h2>Upload Form HTML<\/h2>\n<p>At first, define HTML form elements to allow the user to select a file they want to upload.<br \/>\nMake sure &lt;<span style=\"color:#bf4f24\">form<\/span>> tag contains the following attributes.<\/p>\n<ul class=\"bullet_disk_list\">\n<li>method=&#34;post&#34;<\/li>\n<li>enctype=&#34;multipart\/form-data&#34;<\/li>\n<\/ul>\n<p>Also, make sure &lt;<span style=\"color:#bf4f24\">input<\/span>> tag contains <code>type=\"file\"<\/code> attribute.<\/p>\n<pre>&lt;<span style=\"color:#bf4f24\">form<\/span> <span style=\"color:#bf4f24\">action<\/span>=<span style=\"color:#0b6125\">\"upload.php\"<\/span> <span style=\"color:#bf4f24\">method<\/span>=<span style=\"color:#0b6125\">\"post\"<\/span> <span style=\"color:#bf4f24\">enctype<\/span>=<span style=\"color:#0b6125\">\"multipart\/form-data\"<\/span>>\r\n    Select File to Upload:\r\n    &lt;<span style=\"color:#bf4f24\">input<\/span> <span style=\"color:#bf4f24\">type<\/span>=<span style=\"color:#0b6125\">\"file\"<\/span> <span style=\"color:#bf4f24\">name<\/span>=<span style=\"color:#0b6125\">\"file\"<\/span>>\r\n    &lt;<span style=\"color:#bf4f24\">input<\/span> <span style=\"color:#bf4f24\">type<\/span>=<span style=\"color:#0b6125\">\"submit\"<\/span> <span style=\"color:#bf4f24\">name<\/span>=<span style=\"color:#0b6125\">\"submit\"<\/span> <span style=\"color:#bf4f24\">value<\/span>=<span style=\"color:#0b6125\">\"Upload\"<\/span>>\r\n&lt;\/<span style=\"color:#bf4f24\">form<\/span>>\r\n<\/pre>\n<p>The above file upload form will be submitted to the server-side script (upload.php) for uploading the selected file to the server.<\/p>\n<h2>Upload File in PHP (upload.php)<\/h2>\n<p>This upload.php file contains server-side code to handle the file upload process using PHP.<\/p>\n<ul class=\"bullet_disk_list\">\n<li>PHP provides a built-in function named <b>move_uploaded_file()<\/b> that moves an uploaded file to a new location. Using <code>move_uploaded_file()<\/code> function we can upload a file in PHP.<\/li>\n<li>In the <code>$targetDir<\/code> variable, specify the desire upload folder path where the uploaded file will be stored on the server.<\/li>\n<li>In the <code>$allowTypes<\/code> variable, specify the types of the file in array format that you want to allow to upload.<\/li>\n<li>Use <b>PHP move_uploaded_file()<\/b> function to upload file to the server.<\/li>\n<\/ul>\n<pre><span style=\"color: #0000BB\">&lt;?php<br \/>$statusMsg&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">''<\/span><span style=\"color: #007700\">;<br \/><br \/><\/span><span style=\"color: #FF8000\">\/\/file&nbsp;upload&nbsp;path<br \/><\/span><span style=\"color: #0000BB\">$targetDir&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"uploads\/\"<\/span><span style=\"color: #007700\">;<br \/><\/span><span style=\"color: #0000BB\">$fileName&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">basename<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$_FILES<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">\"file\"<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">\"name\"<\/span><span style=\"color: #007700\">]);<br \/><\/span><span style=\"color: #0000BB\">$targetFilePath&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$targetDir&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">$fileName<\/span><span style=\"color: #007700\">;<br \/><\/span><span style=\"color: #0000BB\">$fileType&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">pathinfo<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$targetFilePath<\/span><span style=\"color: #007700\">,<\/span> <span style=\"color: #0000BB\">PATHINFO_EXTENSION<\/span><span style=\"color: #007700\">);<br \/><br \/>if(isset(<\/span><span style=\"color: #0000BB\">$_POST<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">\"submit\"<\/span><span style=\"color: #007700\">])&nbsp;&amp;&amp;&nbsp;!empty(<\/span><span style=\"color: #0000BB\">$_FILES<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">\"file\"<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">\"name\"<\/span><span style=\"color: #007700\">]))&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/allow&nbsp;certain&nbsp;file&nbsp;formats<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$allowTypes&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;array(<\/span><span style=\"color: #DD0000\">'jpg'<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #DD0000\">'png'<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #DD0000\">'jpeg'<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #DD0000\">'gif'<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #DD0000\">'pdf'<\/span><span style=\"color: #007700\">);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;if(<\/span><span style=\"color: #0000BB\">in_array<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$fileType<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$allowTypes<\/span><span style=\"color: #007700\">)){<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/upload&nbsp;file&nbsp;to&nbsp;server<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">if(<\/span><span style=\"color: #0000BB\">move_uploaded_file<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$_FILES<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">\"file\"<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">\"tmp_name\"<\/span><span style=\"color: #007700\">],&nbsp;<\/span><span style=\"color: #0000BB\">$targetFilePath<\/span><span style=\"color: #007700\">)){<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$statusMsg&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"The&nbsp;file&nbsp;\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$fileName<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">\"&nbsp;has&nbsp;been&nbsp;uploaded.\"<\/span><span style=\"color: #007700\">;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}else{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$statusMsg&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"Sorry,&nbsp;there&nbsp;was&nbsp;an&nbsp;error&nbsp;uploading&nbsp;your&nbsp;file.\"<\/span><span style=\"color: #007700\">;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br \/>&nbsp;&nbsp;&nbsp;&nbsp;}else{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$statusMsg&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'Sorry,&nbsp;only&nbsp;JPG,&nbsp;JPEG,&nbsp;PNG,&nbsp;GIF,&nbsp;&amp;&nbsp;PDF&nbsp;files&nbsp;are&nbsp;allowed&nbsp;to&nbsp;upload.'<\/span><span style=\"color: #007700\">;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;}<br \/>}else{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$statusMsg&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'Please&nbsp;select&nbsp;a&nbsp;file&nbsp;to&nbsp;upload.'<\/span><span style=\"color: #007700\">;<br \/>}<br \/><br \/><\/span><span style=\"color: #FF8000\">\/\/display&nbsp;status&nbsp;message<br \/><\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$statusMsg<\/span><span style=\"color: #007700\">;<br \/><\/span><span style=\"color: #0000BB\">?&gt;<\/span><\/pre>\n<p>You can get the file type using the PHP pathinfo() function with the PATHINFO_EXTENSION flag. This can be used to allow the user to upload only the specific file types and restrict other file types. In this example script, we have allowed users to upload only JPG, JPEG, PNG, GIF, and PDF files, but you can upload any type of files using PHP. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>File upload is the most used feature in web applications. PHP provides an easy way to upload file to the server. With PHP, you can upload files or images to the server by writing minimal <\/p>\n","protected":false},"author":1,"featured_media":2099,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4],"tags":[56,362,14,67],"class_list":["post-2098","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-file-upload","tag-image-upload","tag-php","tag-upload","cat-4-id","has_thumb"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Upload File in PHP - CodexWorld<\/title>\n<meta name=\"description\" content=\"PHP file upload - Learn how to upload file to the server with PHP. PHP script to upload files or images to the server using move_uploaded_file() function.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.codexworld.com\/php-file-upload\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Upload File in PHP - CodexWorld\" \/>\n<meta property=\"og:description\" content=\"PHP file upload - Learn how to upload file to the server with PHP. PHP script to upload files or images to the server using move_uploaded_file() function.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.codexworld.com\/php-file-upload\/\" \/>\n<meta property=\"og:site_name\" content=\"CodexWorld\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:published_time\" content=\"2014-11-30T15:59:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-07-17T05:59:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/01\/how-to-upload-file-in-php-codexworld.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1366\" \/>\n\t<meta property=\"og:image:height\" content=\"768\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"CodexWorld\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@codexworldblog\" \/>\n<meta name=\"twitter:site\" content=\"@codexworldweb\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"CodexWorld\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/php-file-upload\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/php-file-upload\\\/\"},\"author\":{\"name\":\"CodexWorld\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\"},\"headline\":\"How to Upload File in PHP\",\"datePublished\":\"2014-11-30T15:59:52+00:00\",\"dateModified\":\"2024-07-17T05:59:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/php-file-upload\\\/\"},\"wordCount\":317,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/php-file-upload\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2017\\\/01\\\/how-to-upload-file-in-php-codexworld.png\",\"keywords\":[\"File Upload\",\"Image-Upload\",\"PHP\",\"Upload\"],\"articleSection\":[\"PHP\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/php-file-upload\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/php-file-upload\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/php-file-upload\\\/\",\"name\":\"How to Upload File in PHP - CodexWorld\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/php-file-upload\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/php-file-upload\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2017\\\/01\\\/how-to-upload-file-in-php-codexworld.png\",\"datePublished\":\"2014-11-30T15:59:52+00:00\",\"dateModified\":\"2024-07-17T05:59:46+00:00\",\"description\":\"PHP file upload - Learn how to upload file to the server with PHP. PHP script to upload files or images to the server using move_uploaded_file() function.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/php-file-upload\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/php-file-upload\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/php-file-upload\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2017\\\/01\\\/how-to-upload-file-in-php-codexworld.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2017\\\/01\\\/how-to-upload-file-in-php-codexworld.png\",\"width\":1366,\"height\":768,\"caption\":\"how-to-upload-file-in-php-codexworld\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/php-file-upload\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.codexworld.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Upload File in PHP\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"name\":\"CodexWorld\",\"description\":\"Web &amp; Mobile App Development Company\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.codexworld.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\",\"name\":\"CodexWorld\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"width\":200,\"height\":19,\"caption\":\"CodexWorld\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldweb\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/codexworld\",\"https:\\\/\\\/www.youtube.com\\\/codexworld\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\",\"name\":\"CodexWorld\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"caption\":\"CodexWorld\"},\"description\":\"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.\",\"sameAs\":[\"http:\\\/\\\/www.codexworld.com\",\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldblog\"],\"url\":\"https:\\\/\\\/www.codexworld.com\\\/author\\\/nitya192265\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Upload File in PHP - CodexWorld","description":"PHP file upload - Learn how to upload file to the server with PHP. PHP script to upload files or images to the server using move_uploaded_file() function.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.codexworld.com\/php-file-upload\/","og_locale":"en_US","og_type":"article","og_title":"How to Upload File in PHP - CodexWorld","og_description":"PHP file upload - Learn how to upload file to the server with PHP. PHP script to upload files or images to the server using move_uploaded_file() function.","og_url":"https:\/\/www.codexworld.com\/php-file-upload\/","og_site_name":"CodexWorld","article_publisher":"https:\/\/www.facebook.com\/codexworld","article_author":"https:\/\/www.facebook.com\/codexworld","article_published_time":"2014-11-30T15:59:52+00:00","article_modified_time":"2024-07-17T05:59:46+00:00","og_image":[{"width":1366,"height":768,"url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/01\/how-to-upload-file-in-php-codexworld.png","type":"image\/png"}],"author":"CodexWorld","twitter_card":"summary_large_image","twitter_creator":"@codexworldblog","twitter_site":"@codexworldweb","twitter_misc":{"Written by":"CodexWorld","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.codexworld.com\/php-file-upload\/#article","isPartOf":{"@id":"https:\/\/www.codexworld.com\/php-file-upload\/"},"author":{"name":"CodexWorld","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0"},"headline":"How to Upload File in PHP","datePublished":"2014-11-30T15:59:52+00:00","dateModified":"2024-07-17T05:59:46+00:00","mainEntityOfPage":{"@id":"https:\/\/www.codexworld.com\/php-file-upload\/"},"wordCount":317,"commentCount":4,"publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"image":{"@id":"https:\/\/www.codexworld.com\/php-file-upload\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/01\/how-to-upload-file-in-php-codexworld.png","keywords":["File Upload","Image-Upload","PHP","Upload"],"articleSection":["PHP"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.codexworld.com\/php-file-upload\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.codexworld.com\/php-file-upload\/","url":"https:\/\/www.codexworld.com\/php-file-upload\/","name":"How to Upload File in PHP - CodexWorld","isPartOf":{"@id":"https:\/\/www.codexworld.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.codexworld.com\/php-file-upload\/#primaryimage"},"image":{"@id":"https:\/\/www.codexworld.com\/php-file-upload\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/01\/how-to-upload-file-in-php-codexworld.png","datePublished":"2014-11-30T15:59:52+00:00","dateModified":"2024-07-17T05:59:46+00:00","description":"PHP file upload - Learn how to upload file to the server with PHP. PHP script to upload files or images to the server using move_uploaded_file() function.","breadcrumb":{"@id":"https:\/\/www.codexworld.com\/php-file-upload\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.codexworld.com\/php-file-upload\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/php-file-upload\/#primaryimage","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/01\/how-to-upload-file-in-php-codexworld.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/01\/how-to-upload-file-in-php-codexworld.png","width":1366,"height":768,"caption":"how-to-upload-file-in-php-codexworld"},{"@type":"BreadcrumbList","@id":"https:\/\/www.codexworld.com\/php-file-upload\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.codexworld.com\/"},{"@type":"ListItem","position":2,"name":"How to Upload File in PHP"}]},{"@type":"WebSite","@id":"https:\/\/www.codexworld.com\/#website","url":"https:\/\/www.codexworld.com\/","name":"CodexWorld","description":"Web &amp; Mobile App Development Company","publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.codexworld.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.codexworld.com\/#organization","name":"CodexWorld","url":"https:\/\/www.codexworld.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","width":200,"height":19,"caption":"CodexWorld"},"image":{"@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldweb","https:\/\/www.linkedin.com\/company\/codexworld","https:\/\/www.youtube.com\/codexworld"]},{"@type":"Person","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0","name":"CodexWorld","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","caption":"CodexWorld"},"description":"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.","sameAs":["http:\/\/www.codexworld.com","https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldblog"],"url":"https:\/\/www.codexworld.com\/author\/nitya192265\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/01\/how-to-upload-file-in-php-codexworld.png","jetpack_shortlink":"https:\/\/wp.me\/p6bxIh-xQ","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/2098","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/comments?post=2098"}],"version-history":[{"count":6,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/2098\/revisions"}],"predecessor-version":[{"id":5690,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/2098\/revisions\/5690"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media\/2099"}],"wp:attachment":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media?parent=2098"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/categories?post=2098"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/tags?post=2098"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}